You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
using AppContext.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Model;
|
|
|
|
namespace Converters;
|
|
|
|
public static class EntitiesToModels
|
|
{
|
|
public static User ToModel(this UserEntity entity)
|
|
{
|
|
return new User(entity.Id, entity.Name, entity.Email, entity.ProfilePicture, entity.IsAdmin);
|
|
}
|
|
|
|
public static Tactic ToModel(this TacticEntity entity)
|
|
{
|
|
return new Tactic(entity.Id, entity.Name, entity.OwnerId, entity.Type, entity.CreationDate);
|
|
}
|
|
|
|
public static TacticStep ToModel(this TacticStepEntity entity, IQueryable<TacticStepEntity> steps)
|
|
{
|
|
return new TacticStep(
|
|
entity.Id,
|
|
entity.ParentId,
|
|
steps.Where(s =>s.TacticId == entity.TacticId && s.ParentId == entity.Id)
|
|
.AsEnumerable()
|
|
.Select(e => e.ToModel(steps)),
|
|
entity.JsonContent
|
|
);
|
|
}
|
|
|
|
public static Team ToModel(this TeamEntity entity)
|
|
{
|
|
return new Team(entity.Id, entity.Name, entity.Picture, entity.MainColor, entity.SecondColor);
|
|
}
|
|
|
|
public static Member ToModel(this MemberEntity entity)
|
|
{
|
|
return new Member(entity.TeamId, entity.UserId, entity.Role);
|
|
}
|
|
} |