public async Task Edit(string hallId, StandViewModel stand, IFormFile file, IEnumerable <string> exhibits, byte[] photo) { var initialStand = await _standsRepository.GetAsync(hallId, stand.Id); stand.Exhibits = new List <ExhibitViewModel>(); foreach (var id in exhibits) { stand.Exhibits.Add(initialStand.Exhibits.First(e => e.Id.Equals(id))); } if (initialStand.Photo != null) { stand.Photo = initialStand.Photo; if (photo == null) { stand.Photo.Photo = null; } } if (file != null) { await _formFileToByteConverterService.ConvertAsync(file, stand); } await _standsRepository.UpdateAsync(hallId, stand.Id, stand); }
public async Task <IActionResult> UpdateAsync(string hallId, Stand standIn) { standIn.Id.ValidateId(); hallId.ValidateId(); var stand = await _standsRepository.GetAsync(hallId, standIn.Id); if (stand == null) { return(NotFound()); } try { await _standsRepository.UpdateAsync(hallId, standIn.Id, standIn); } catch (Exception) { throw new Error(Errors.Update_error, $"Can not update record {stand}"); } return(NoContent()); }