public async Task <HbResult <HbLot> > Update(UpdateLotForm form) { var lot = await _dc.Lots.FirstOrDefaultAsync(u => u.Id == form.Id && !u.IsDeleted); if (lot == null) { return(new HbResult <HbLot>(ErrorCodes.LotNotFound)); } lot.Identifier = form.IdentifierNumber; await _dc.SaveChangesAsync(); return(new HbResult <HbLot>(_mapper.Map <HbLot>(lot))); }
public async Task <IActionResult> Edit(UpdateLotForm form) { if (!ModelState.IsValid) { return(View(form)); } var res = await _lots.Update(form); if (res.IsCorrect) { return(RedirectToAction(nameof(List))); } ViewData[ViewDataKeys.ErrorMessage] = res.ErrorMessage; return(View(form)); }