Add machines creation in admin view.

This commit is contained in:
2020-05-28 02:57:49 +01:00
parent 8c9a0c9111
commit 8a9b6eb292
7 changed files with 44 additions and 343 deletions

View File

@@ -61,6 +61,20 @@ namespace Marechai.Services
await _context.SaveChangesAsync();
}
public async Task<int> CreateAsync(MachineViewModel viewModel)
{
var model = new Machine
{
CompanyId = viewModel.CompanyId, Name = viewModel.Name, Model = viewModel.Model,
Introduced = viewModel.Introduced, Type = viewModel.Type, FamilyId = viewModel.FamilyId
};
await _context.Machines.AddAsync(model);
await _context.SaveChangesAsync();
return model.Id;
}
public async Task<MachineViewModel> GetMachine(int id)
{
Machine machine = await _context.Machines.FindAsync(id);