Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
У пользователя появилось поле для хранения base64 файла с аватаркой
Browse files Browse the repository at this point in the history
  • Loading branch information
nzour committed Jan 3, 2020
1 parent f3c584e commit 75edabf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/Application/CQS/Profile/ProfileOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ public class ProfileOutput
public string LastName { get; }
public string Login { get; }
public UserRole Role { get; }
public string? Avatar { get; }

public ProfileOutput(UserEntity entity)
public ProfileOutput(UserEntity user)
{
Id = entity.Id;
FirstName = entity.FirstName;
LastName = entity.LastName;
Login = entity.Login;
Role = entity.Role;
Id = user.Id;
FirstName = user.FirstName;
LastName = user.LastName;
Login = user.Login;
Role = user.Role;
Avatar = user.Avatar;
}
}
}
5 changes: 5 additions & 0 deletions src/Domain/Entities/UserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class UserEntity
public string Login { get; protected internal set; }
public string Password { get; set; }
public UserRole Role { get; protected internal set; }

/// <summary>
/// Base64 изображения.
/// </summary>
public string? Avatar { get; set; }
public ISet<ReservationEntity> Reservations { get; protected internal set; } = new HashSet<ReservationEntity>();

public UserEntity(string firstName, string lastName, string login, string password, UserRole role)
Expand Down
3 changes: 2 additions & 1 deletion src/Infrastructure/NHibernate/Mapping/UserMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public UserMap()
Map(x => x.LastName).Not.Nullable();
Map(x => x.Login).Not.Nullable().Unique();
Map(x => x.Password).Not.Nullable();
Map(x => x.Avatar, "AvatarBase64").Nullable();

Map(x => x.Role)
.CustomType<EnumStringType<UserRole>>()
.Not.Nullable();

HasMany(x => x.Reservations).KeyColumn("UserId");
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/Infrastructure/NHibernate/Migration/Migration20200103001.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using FluentMigrator;

namespace Infrastructure.NHibernate.Migration
{
[Migration(20200103001)]
public class Migration20200103001 : FluentMigrator.Migration
{
public override void Up()
{
Alter.Table("Users").AddColumn("AvatarBase64").AsString().Nullable();
}

public override void Down()
{
Delete.Column("AvatarBase64").FromTable("Users");
}
}
}

0 comments on commit 75edabf

Please sign in to comment.