This commit is contained in:
Natlinux
2022-11-13 18:10:38 +01:00
parent d2c021c5b7
commit ee8c687f5c
13 changed files with 380 additions and 8 deletions

View File

@@ -0,0 +1,42 @@
using Apollon.Domain.Commands;
using Apollon.Domain.Models;
using Apollon.EntityFramework.DTOs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.EntityFramework.Commands
{
public class CreateNameListCommand : ICreateNameListCommand
{
private readonly ApplicationDBContextFactory _contextFactory;
public CreateNameListCommand(ApplicationDBContextFactory dbContextFactory)
{
_contextFactory = dbContextFactory;
}
public async Task Execute(NameList nameList)
{
using (ApplicationDbContext context = _contextFactory.Create())
{
NameListDto nameListDto = new NameListDto()
{
Id = nameList.Id,
FirstName = nameList.FirstName,
LastName = nameList.Country,
PassNumber = nameList.PassNumber,
Society = nameList.Society,
SocietyNumber = nameList.SocietyNumber,
Birthday = nameList.Birthday,
Country = nameList.Country,
};
context.NameList.Add(nameListDto);
await context.SaveChangesAsync();
}
}
}
}