Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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");
        }