public ActionResult Edit(int id) { WorkContext.Breadcrumbs.Add(new Breadcrumb { Text = T("Quản lý thể tích chai"), Url = Url.Action("Index") }); WorkContext.Breadcrumbs.Add(new Breadcrumb { Text = T("Thể tích chai"), Url = "#" }); var model = new ProductVolumeModel(); if (id > 0) { model = this.service.GetById(id); } var result = new ControlFormResult <ProductVolumeModel>(model); result.Title = this.T("Thể tích chai"); result.FormMethod = FormMethod.Post; result.UpdateActionName = "Update"; result.ShowCancelButton = false; result.ShowBoxHeader = false; result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml; result.FormWrapperEndHtml = Constants.Form.FormWrapperEndHtml; result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success); result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger); return(result); }
public ActionResult Update(ProductVolumeModel model) { if (!ModelState.IsValid) { return(new AjaxResult().Alert(T(Constants.Messages.InvalidModel))); } ProductVolumeInfo item; if (model.Id == 0) { item = new ProductVolumeInfo(); } else { item = service.GetById(model.Id); } item.Name = model.Name; service.Save(item); return(new AjaxResult().NotifyMessage("UPDATE_ENTITY_COMPLETE").CloseModalDialog()); }