public ActionResult Edit(UpdateCellarInput viewModel) { try { if (ModelState.IsValid) { viewModel.CompanyName = _currentUser.CompanyName; viewModel.LastModifierUserId = _currentUser.CurrentUserId; _cellarService.Update(viewModel); viewModel.ErrorCode = ErrorCodeHelper.Ok; viewModel.WareHouseUsers = _cellarService.GetAllWareHouseUsers(_currentUser.CompanyName); viewModel.ErrorDescription = "¡Ubicación guardada exitosamente!"; return(PartialView("_editPartial", viewModel)); } viewModel.ErrorCode = ErrorCodeHelper.Error; viewModel.WareHouseUsers = _cellarService.GetAllWareHouseUsers(_currentUser.CompanyName); viewModel.ErrorDescription = "Error en los datos."; return(PartialView("_editPartial", viewModel)); } catch (Exception e) { viewModel.ErrorCode = ErrorCodeHelper.Error; viewModel.WareHouseUsers = _cellarService.GetAllWareHouseUsers(_currentUser.CompanyName); viewModel.ErrorDescription = e.Message; return(PartialView("_editPartial", viewModel)); } }
public void Update(UpdateCellarInput input) { var @entity = _cellarRepository.Get(input.Id); if (@entity == null) { throw new UserFriendlyException("No se pudo encontrar la Ubicación, fue borrada o no existe."); } if (_cellarManager.CellarExist(input.Name, input.Id, input.CompanyName)) { throw new UserFriendlyException("Existe una Ubicación con el mismo Nombre."); } @entity.Name = input.Name; @entity.Address = input.Address; @entity.Phone = input.Phone; @entity.WareHouseManagerId = input.WareHouseManagerId; @entity.Latitude = input.Latitude; @entity.Longitude = input.Longitude; @entity.CostCenter = input.CostCenter; @entity.LastModificationTime = _dateTime.Now; @entity.LastModifierUserId = input.LastModifierUserId; _cellarRepository.Update(@entity); }
public ActionResult Edit(Guid id) { UpdateCellarInput viewModel = new UpdateCellarInput(); try { viewModel.CompanyName = _currentUser.CompanyName; viewModel = _cellarService.GetEdit(id); viewModel.WareHouseUsers = _cellarService.GetAllWareHouseUsers(_currentUser.CompanyName); viewModel.ErrorCode = ErrorCodeHelper.None; viewModel.ErrorDescription = ""; } catch (Exception e) { viewModel.ErrorCode = ErrorCodeHelper.Error; viewModel.ErrorDescription = "Error al obtener datos."; } return(PartialView("_editPartial", viewModel)); }