public ActionResult DeleteAjaxCustomerPackGrid([DataSourceRequest] DataSourceRequest request, CustomerPackViewModel model) { if (ModelState.IsValid) { try { var customerPack = _customerPackService.GetByCustomerAndId(_appUserContext.Current.CurrentCustomer.Id, model.Id); if (customerPack == null) { _contextManager.ResponseManager.StatusCode = 500; _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, WebResources.CustomerPackCannotBeFound); } else { _customerPackService.Delete(customerPack); } } catch (Exception ex) { _contextManager.ResponseManager.StatusCode = 500; _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message); } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public ActionResult UpdateAjaxCustomerPackGrid([DataSourceRequest] DataSourceRequest request, CustomerPackViewModel model) { if (ModelState.IsValid) { try { if (_appUserContext.Current.CurrentCustomer != null) { var customerPack = _customerPackService.GetByCustomerAndId(_appUserContext.Current.CurrentCustomer.Id, model.Id); if (customerPack != null) { customerPack.PackNotes = model.PackNotes; customerPack.Filename = model.Filename; customerPack.UpdatedDate = DateTime.Now; customerPack.UpdatedBy = _contextManager.UserManager.Name; _customerPackService.Update(customerPack); } else { ModelState.AddModelError(ModelStateErrorNames.CustomerPackCannotBeFound, WebResources.CustomerPackCannotBeFound); } } } catch (Exception ex) { _contextManager.ResponseManager.StatusCode = 500; _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message); } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }