public async Task Create(PlasticSpoolViewModel plasticSpoolViewModel) { var data = plasticSpoolViewModel.DtoModel(); if (plasticSpoolViewModel.Id == 0) { await _plasticSpoolService.Create(data); } if (plasticSpoolViewModel.Id != 0) { await _plasticSpoolService.Update(data); } }
public async Task <List <int> > UploadSpools(List <int> plasticIds) { var spools = new List <Domains.PlasticSpool.PlasticSpool> { new Domains.PlasticSpool.PlasticSpool { Id = 0, Mass = 1000, SellValue = 29.99, TimeToManufacture = new TimeSpan(15, 0, 0), ManufactureCost = 5.00, PlasticId = plasticIds[0] }, new Domains.PlasticSpool.PlasticSpool { Id = 0, Mass = 1000, SellValue = 19.61, TimeToManufacture = new TimeSpan(23, 0, 0), ManufactureCost = 3.25, PlasticId = plasticIds[2] }, new Domains.PlasticSpool.PlasticSpool { Id = 0, Mass = 1000, SellValue = 84.20, TimeToManufacture = new TimeSpan(23, 0, 0), ManufactureCost = 15.45, PlasticId = plasticIds[4] }, new Domains.PlasticSpool.PlasticSpool { Id = 0, Mass = 1000, SellValue = 25, TimeToManufacture = new TimeSpan(10, 0, 0), ManufactureCost = 2.25, PlasticId = plasticIds[5] } }; var spoolIds = new List <int>(); foreach (var spool in spools) { spoolIds.Add((await _spoolRepository.Create(new PlasticSpoolDto(spool))).Id); } return(spoolIds); }