Пример #1
0
        public async Task <IActionResult> UpdateAssignment(int id, AssignmentForUpdateDto assignmentForUpdateDto)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var assignmentFromRepo = await _repo.GetAssignment(assignmentForUpdateDto.Id);

            _mapper.Map(assignmentForUpdateDto, assignmentFromRepo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

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