Esempio n. 1
0
        public async Task <IActionResult> UpdateProduction(int userId, int id, ProdForUpdateDto prodForUpdateDto)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var prodFromRepo = await _repo.GetProduction(id);

            _mapper.Map(prodForUpdateDto, prodFromRepo);

            if (await _repo.SaveAll())
            {
                return(CreatedAtRoute("GetProd", new { id = prodFromRepo.Id, userId = userId }, prodForUpdateDto));
            }

            throw new Exception($"Updating production lot {id} failed on save");
        }