public async Task <bool> UpdateInventory(Computer computer) { var computerFromRepo = await _repo.GetComputer(computer.Id); computerFromRepo.Inventory = new string("1-" + computerFromRepo.Id); return(await _repo.SaveAll()); }
public async Task <IActionResult> AddComputer([FromBody] ComputerNewDto computerNewDto) { var computerToAdd = _mapper.Map <Computer>(computerNewDto); _repo.Add(computerToAdd); if (await _repo.SaveAll()) { if (await _idToInventory.UpdateInventory(computerToAdd)) { return(NoContent()); } } throw new Exception($"Creating meeting failed on save"); }