mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add machines creation in admin view.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user