Added the language to the user profile and fixed a putin bug

pull/3632/head
tidusjar 5 years ago
parent e1265046b5
commit 282f5a5d4e

@ -72,7 +72,7 @@ namespace Ombi.Core.Engine.V2
}
// Setup the task so we can get the data later on if we have a IMDBID
Task<TraktShow> traktInfoTask = new Task<TraktShow>(() => null);
Task<TraktShow> traktInfoTask = null;
if (show.externals?.imdb.HasValue() ?? false)
{
traktInfoTask = Cache.GetOrAdd("GetExtendedTvInfoTrakt" + show.externals?.imdb,
@ -167,6 +167,8 @@ namespace Ombi.Core.Engine.V2
}
private async Task<SearchFullInfoTvShowViewModel> GetExtraInfo(Task<TraktShow> showInfoTask, SearchFullInfoTvShowViewModel model)
{
if (showInfoTask != null)
{
var result = await showInfoTask;
if (result == null)
@ -177,7 +179,7 @@ namespace Ombi.Core.Engine.V2
model.Trailer = result.Trailer?.AbsoluteUri ?? string.Empty;
model.Certification = result.Certification;
model.Homepage = result.Homepage?.AbsoluteUri ?? string.Empty;
}
return model;
}
}

@ -21,6 +21,8 @@ namespace Ombi.Store.Entities
public string EmbyConnectUserId { get; set; }
public string Language { get; set; }
public int? MovieRequestLimit { get; set; }
public int? EpisodeRequestLimit { get; set; }
public int? MusicRequestLimit { get; set; }

File diff suppressed because it is too large Load Diff

@ -0,0 +1,23 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiMySql
{
public partial class UserProfile : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Language",
table: "AspNetUsers",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Language",
table: "AspNetUsers");
}
}
}

@ -269,6 +269,9 @@ namespace Ombi.Store.Migrations.OmbiMySql
b.Property<int?>("EpisodeRequestLimit")
.HasColumnType("int");
b.Property<string>("Language")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<DateTime?>("LastLoggedIn")
.HasColumnType("datetime(6)");
@ -592,6 +595,9 @@ namespace Ombi.Store.Migrations.OmbiMySql
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Description")
.HasColumnType("longtext CHARACTER SET utf8mb4");

File diff suppressed because it is too large Load Diff

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiSqlite
{
public partial class UserProfile : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Language",
table: "AspNetUsers",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Language",
table: "AspNetUsers");
}
}
}

@ -268,6 +268,9 @@ namespace Ombi.Store.Migrations.OmbiSqlite
b.Property<int?>("EpisodeRequestLimit")
.HasColumnType("INTEGER");
b.Property<string>("Language")
.HasColumnType("TEXT");
b.Property<DateTime?>("LastLoggedIn")
.HasColumnType("TEXT");

@ -286,6 +286,21 @@ namespace Ombi.Controllers.V1
return await GetUserWithRoles(user);
}
/// <summary>
/// Sets the current users language
/// </summary>
[HttpPost("language")]
[Authorize]
public async Task<IActionResult> SetCurrentUserLanguage([FromBody] UserLanguage model)
{
var username = User.Identity.Name.ToUpper();
var user = await UserManager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username);
user.Language = model.Lang;
await UserManager.UpdateAsync(user);
return Ok();
}
/// <summary>
/// Gets the user by the user id.
/// </summary>

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Ombi.Models.Identity
{
public class UserLanguage
{
public string Lang { get; set; }
}
}
Loading…
Cancel
Save