public async Task <CassetteProperties> UpdateAsync(CassetteProperties request) { int id; if (int.TryParse(request.Num, out id)) { int[] realContainersId = new int[] { id }; var statuses = await _realContainerRepo.GetStatusesAsync(); int?realContainerStatusId = statuses.ToList().Find(s => s.Name == request.Status)?.IdType; if (realContainerStatusId.HasValue) { await _realContainerRepo.UpdateStatusAsync(realContainersId, realContainerStatusId.Value, false); } await _realContainerRepo.SetPropertiesAsync(realContainersId, request.AtRemove, request.AtCheck); var cas = await _realContainerRepo.GetAsync(realContainersId); return(_mapper.Map <RealContainer, CassetteProperties>(cas?.FirstOrDefault())); } return(null); }
public async Task <IActionResult> UpdateAsync([FromBody][Required] CassetteProperties request) { var result = await _cassetteService.UpdateAsync(request); if (result == null) { return(BadRequest(new { errorMessage = $"Кассета с номером {request.Num} в базе не обнаружена" })); } else { return(Ok(result)); } }