public async Task <IActionResult> UpdateMachine(int userId, string mach, MachForUpdateDto machForUpdateDto) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var machFromRepo = await _repo.GetMachine(userId, mach); machFromRepo.CurrentJob = machForUpdateDto.CurrentJob; machFromRepo.CurrentOp = machForUpdateDto.CurrentOp; if (await _repo.SaveAll()) { return(CreatedAtRoute("GetMach", new { mach = machFromRepo.Machine, userId = userId }, machForUpdateDto)); } throw new Exception($"Updating machine {mach} failed on save"); }