Added new migrations

pull/3400/head
Jamie Rees 4 years ago
parent 993510efdd
commit a482a095ab

@ -5,6 +5,7 @@ namespace Ombi.Store.Context.MySql
public sealed class OmbiMySqlContext : OmbiContext
{
private static bool _created;
public OmbiMySqlContext(DbContextOptions<OmbiMySqlContext> options) : base(options)
{
if (_created) return;

@ -18,6 +18,7 @@ namespace Ombi.Store.Context
}
/// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
@ -50,6 +51,7 @@ namespace Ombi.Store.Context
public DbSet<Tokens> Tokens { get; set; }
public DbSet<RequestSubscription> RequestSubscription { get; set; }
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
public DbSet<MobileDevices> MobileDevices { get; set; }
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
public DbSet<RequestQueue> RequestQueue { get; set; }

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Ombi.Store.Entities
{
public class MobileDevices : Entity
{
public string Token { get; set; }
public string UserId { get; set; }
public DateTime AddedAt { get; set; }
[ForeignKey(nameof(UserId))]
public OmbiUser User { get; set; }
}
}

@ -14,15 +14,17 @@ namespace Ombi.Store.Migrations.ExternalMySql
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("ProductVersion", "3.1.1")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("TheMovieDbId");
b.Property<int>("TheMovieDbId")
.HasColumnType("int");
b.HasKey("Id");
@ -32,26 +34,36 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("AddedAt");
b.Property<DateTime>("AddedAt")
.HasColumnType("datetime(6)");
b.Property<string>("EmbyId")
.IsRequired();
.IsRequired()
.HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("ImdbId");
b.Property<string>("ImdbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ProviderId");
b.Property<string>("ProviderId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("TheMovieDbId");
b.Property<string>("TheMovieDbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Title");
b.Property<string>("Title")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("TvDbId");
b.Property<string>("TvDbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("Type");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<string>("Url");
b.Property<string>("Url")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
@ -61,27 +73,38 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("AddedAt");
b.Property<DateTime>("AddedAt")
.HasColumnType("datetime(6)");
b.Property<string>("EmbyId");
b.Property<string>("EmbyId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("EpisodeNumber");
b.Property<int>("EpisodeNumber")
.HasColumnType("int");
b.Property<string>("ImdbId");
b.Property<string>("ImdbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ParentId");
b.Property<string>("ParentId")
.HasColumnType("varchar(255) CHARACTER SET utf8mb4");
b.Property<string>("ProviderId");
b.Property<string>("ProviderId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("SeasonNumber");
b.Property<int>("SeasonNumber")
.HasColumnType("int");
b.Property<string>("TheMovieDbId");
b.Property<string>("TheMovieDbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Title");
b.Property<string>("Title")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("TvDbId");
b.Property<string>("TvDbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
@ -93,23 +116,32 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("AddedAt");
b.Property<DateTime>("AddedAt")
.HasColumnType("datetime(6)");
b.Property<int>("ArtistId");
b.Property<int>("ArtistId")
.HasColumnType("int");
b.Property<string>("ForeignAlbumId");
b.Property<string>("ForeignAlbumId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<bool>("Monitored");
b.Property<bool>("Monitored")
.HasColumnType("tinyint(1)");
b.Property<decimal>("PercentOfTracks");
b.Property<decimal>("PercentOfTracks")
.HasColumnType("decimal(65,30)");
b.Property<DateTime>("ReleaseDate");
b.Property<DateTime>("ReleaseDate")
.HasColumnType("datetime(6)");
b.Property<string>("Title");
b.Property<string>("Title")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("TrackCount");
b.Property<int>("TrackCount")
.HasColumnType("int");
b.HasKey("Id");
@ -119,15 +151,20 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("ArtistId");
b.Property<int>("ArtistId")
.HasColumnType("int");
b.Property<string>("ArtistName");
b.Property<string>("ArtistName")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ForeignArtistId");
b.Property<string>("ForeignArtistId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<bool>("Monitored");
b.Property<bool>("Monitored")
.HasColumnType("tinyint(1)");
b.HasKey("Id");
@ -137,19 +174,26 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("EpisodeNumber");
b.Property<int>("EpisodeNumber")
.HasColumnType("int");
b.Property<int>("GrandparentKey");
b.Property<int>("GrandparentKey")
.HasColumnType("int");
b.Property<int>("Key");
b.Property<int>("Key")
.HasColumnType("int");
b.Property<int>("ParentKey");
b.Property<int>("ParentKey")
.HasColumnType("int");
b.Property<int>("SeasonNumber");
b.Property<int>("SeasonNumber")
.HasColumnType("int");
b.Property<string>("Title");
b.Property<string>("Title")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
@ -161,17 +205,23 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("ParentKey");
b.Property<int>("ParentKey")
.HasColumnType("int");
b.Property<int>("PlexContentId");
b.Property<int>("PlexContentId")
.HasColumnType("int");
b.Property<int?>("PlexServerContentId");
b.Property<int?>("PlexServerContentId")
.HasColumnType("int");
b.Property<int>("SeasonKey");
b.Property<int>("SeasonKey")
.HasColumnType("int");
b.Property<int>("SeasonNumber");
b.Property<int>("SeasonNumber")
.HasColumnType("int");
b.HasKey("Id");
@ -183,29 +233,41 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("AddedAt");
b.Property<DateTime>("AddedAt")
.HasColumnType("datetime(6)");
b.Property<string>("ImdbId");
b.Property<string>("ImdbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("Key");
b.Property<int>("Key")
.HasColumnType("int");
b.Property<string>("Quality");
b.Property<string>("Quality")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("ReleaseYear");
b.Property<string>("ReleaseYear")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int?>("RequestId");
b.Property<int?>("RequestId")
.HasColumnType("int");
b.Property<string>("TheMovieDbId");
b.Property<string>("TheMovieDbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("Title");
b.Property<string>("Title")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<string>("TvDbId");
b.Property<string>("TvDbId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("Type");
b.Property<int>("Type")
.HasColumnType("int");
b.Property<string>("Url");
b.Property<string>("Url")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
@ -215,11 +277,14 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<bool>("HasFile");
b.Property<bool>("HasFile")
.HasColumnType("tinyint(1)");
b.Property<int>("TheMovieDbId");
b.Property<int>("TheMovieDbId")
.HasColumnType("int");
b.HasKey("Id");
@ -229,9 +294,11 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("TvDbId");
b.Property<int>("TvDbId")
.HasColumnType("int");
b.HasKey("Id");
@ -241,13 +308,17 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("EpisodeNumber");
b.Property<int>("EpisodeNumber")
.HasColumnType("int");
b.Property<int>("SeasonNumber");
b.Property<int>("SeasonNumber")
.HasColumnType("int");
b.Property<int>("TvDbId");
b.Property<int>("TvDbId")
.HasColumnType("int");
b.HasKey("Id");
@ -257,9 +328,11 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("TvDbId");
b.Property<int>("TvDbId")
.HasColumnType("int");
b.HasKey("Id");
@ -269,15 +342,20 @@ namespace Ombi.Store.Migrations.ExternalMySql
modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("EpisodeNumber");
b.Property<int>("EpisodeNumber")
.HasColumnType("int");
b.Property<bool>("HasFile");
b.Property<bool>("HasFile")
.HasColumnType("tinyint(1)");
b.Property<int>("SeasonNumber");
b.Property<int>("SeasonNumber")
.HasColumnType("int");
b.Property<int>("TvDbId");
b.Property<int>("TvDbId")
.HasColumnType("int");
b.HasKey("Id");
@ -298,12 +376,13 @@ namespace Ombi.Store.Migrations.ExternalMySql
.WithMany("Episodes")
.HasForeignKey("GrandparentKey")
.HasPrincipalKey("Key")
.OnDelete(DeleteBehavior.Cascade);
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
{
b.HasOne("Ombi.Store.Entities.PlexServerContent")
b.HasOne("Ombi.Store.Entities.PlexServerContent", null)
.WithMany("Seasons")
.HasForeignKey("PlexServerContentId");
});

@ -0,0 +1,64 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiMySql
{
public partial class MobileDevices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "EpisodeNumber",
table: "Issues",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "SeasonNumber",
table: "Issues",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "MobileDevices",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Token = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true),
AddedAt = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MobileDevices", x => x.Id);
table.ForeignKey(
name: "FK_MobileDevices_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_MobileDevices_UserId",
table: "MobileDevices",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MobileDevices");
migrationBuilder.DropColumn(
name: "EpisodeNumber",
table: "Issues");
migrationBuilder.DropColumn(
name: "SeasonNumber",
table: "Issues");
}
}
}

@ -0,0 +1,214 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiSqlite
{
public partial class MobileDevices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EmbyEpisode");
migrationBuilder.DropTable(
name: "PlexEpisode");
migrationBuilder.DropTable(
name: "PlexSeasonsContent");
migrationBuilder.DropTable(
name: "EmbyContent");
migrationBuilder.DropTable(
name: "PlexServerContent");
migrationBuilder.AddColumn<int>(
name: "EpisodeNumber",
table: "Issues",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "SeasonNumber",
table: "Issues",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "MobileDevices",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Token = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true),
AddedAt = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MobileDevices", x => x.Id);
table.ForeignKey(
name: "FK_MobileDevices_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_MobileDevices_UserId",
table: "MobileDevices",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MobileDevices");
migrationBuilder.DropColumn(
name: "EpisodeNumber",
table: "Issues");
migrationBuilder.DropColumn(
name: "SeasonNumber",
table: "Issues");
migrationBuilder.CreateTable(
name: "EmbyContent",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AddedAt = table.Column<DateTime>(nullable: false),
EmbyId = table.Column<string>(nullable: false),
ImdbId = table.Column<string>(nullable: true),
ProviderId = table.Column<string>(nullable: true),
TheMovieDbId = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
TvDbId = table.Column<string>(nullable: true),
Type = table.Column<int>(nullable: false),
Url = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmbyContent", x => x.Id);
table.UniqueConstraint("AK_EmbyContent_EmbyId", x => x.EmbyId);
});
migrationBuilder.CreateTable(
name: "PlexServerContent",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AddedAt = table.Column<DateTime>(nullable: false),
ImdbId = table.Column<string>(nullable: true),
Key = table.Column<int>(nullable: false),
Quality = table.Column<string>(nullable: true),
ReleaseYear = table.Column<string>(nullable: true),
RequestId = table.Column<int>(nullable: true),
TheMovieDbId = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
TvDbId = table.Column<string>(nullable: true),
Type = table.Column<int>(nullable: false),
Url = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlexServerContent", x => x.Id);
table.UniqueConstraint("AK_PlexServerContent_Key", x => x.Key);
});
migrationBuilder.CreateTable(
name: "EmbyEpisode",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AddedAt = table.Column<DateTime>(nullable: false),
EmbyId = table.Column<string>(nullable: true),
EpisodeNumber = table.Column<int>(nullable: false),
ImdbId = table.Column<string>(nullable: true),
ParentId = table.Column<string>(nullable: true),
ProviderId = table.Column<string>(nullable: true),
SeasonNumber = table.Column<int>(nullable: false),
TheMovieDbId = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
TvDbId = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmbyEpisode", x => x.Id);
table.ForeignKey(
name: "FK_EmbyEpisode_EmbyContent_ParentId",
column: x => x.ParentId,
principalTable: "EmbyContent",
principalColumn: "EmbyId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "PlexEpisode",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
EpisodeNumber = table.Column<int>(nullable: false),
GrandparentKey = table.Column<int>(nullable: false),
Key = table.Column<int>(nullable: false),
ParentKey = table.Column<int>(nullable: false),
SeasonNumber = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PlexEpisode", x => x.Id);
table.ForeignKey(
name: "FK_PlexEpisode_PlexServerContent_GrandparentKey",
column: x => x.GrandparentKey,
principalTable: "PlexServerContent",
principalColumn: "Key",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PlexSeasonsContent",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ParentKey = table.Column<int>(nullable: false),
PlexContentId = table.Column<int>(nullable: false),
PlexServerContentId = table.Column<int>(nullable: true),
SeasonKey = table.Column<int>(nullable: false),
SeasonNumber = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PlexSeasonsContent", x => x.Id);
table.ForeignKey(
name: "FK_PlexSeasonsContent_PlexServerContent_PlexServerContentId",
column: x => x.PlexServerContentId,
principalTable: "PlexServerContent",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_EmbyEpisode_ParentId",
table: "EmbyEpisode",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_PlexEpisode_GrandparentKey",
table: "PlexEpisode",
column: "GrandparentKey");
migrationBuilder.CreateIndex(
name: "IX_PlexSeasonsContent_PlexServerContentId",
table: "PlexSeasonsContent",
column: "PlexServerContentId");
}
}
}

@ -0,0 +1,60 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core.Authentication;
using Ombi.Models.V2;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Ombi.Controllers.V2
{
[ApiV2]
[Authorize]
[Produces("application/json")]
[ApiController]
public class MobileController : ControllerBase
{
public MobileController(IRepository<MobileDevices> mobileDevices, OmbiUserManager user)
{
_mobileDevices = mobileDevices;
_userManager = user;
}
private readonly IRepository<MobileDevices> _mobileDevices;
private readonly OmbiUserManager _userManager;
[HttpPost("Notification")]
[ApiExplorerSettings(IgnoreApi = true)]
[ProducesResponseType(400)]
[ProducesResponseType(200)]
public async Task<IActionResult> AddNotitficationId([FromBody] MobileNotificationBody body)
{
if (!string.IsNullOrEmpty(body?.Token))
{
var user = await _userManager.Users.FirstOrDefaultAsync(x => x.UserName.Equals(User.Identity.Name, StringComparison.InvariantCultureIgnoreCase));
// Check if we already have this notification id
var alreadyExists = await _mobileDevices.GetAll().AnyAsync(x => x.Token == body.Token && x.UserId == user.Id);
if (alreadyExists)
{
return Ok();
}
// let's add it
await _mobileDevices.Add(new MobileDevices
{
Token = body.Token,
UserId = user.Id,
AddedAt = DateTime.Now,
});
return Ok();
}
return BadRequest();
}
}
}

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Ombi.Models.V2
{
public class MobileNotificationBody
{
public string Token { get; set; }
}
}

@ -63,6 +63,7 @@ namespace Ombi
{
services.AddIdentity<OmbiUser, IdentityRole>()
.AddEntityFrameworkStores<OmbiContext>()
.AddRoles<IdentityRole>()
.AddDefaultTokenProviders()
.AddUserManager<OmbiUserManager>();

Loading…
Cancel
Save