public ActionResult Edit(int id) { WorkContext.Breadcrumbs.Add(new Breadcrumb { Text = T("Thông tin dòng sản phẩm"), Url = Url.Action("Index") }); var model = new ProductsGroupModel(); if (id > 0) { model = this.service.GetById(id); } var result = new ControlFormResult <ProductsGroupModel>(model); result.Title = this.T("Thông tin dòng sản phẩm"); result.FormMethod = FormMethod.Post; result.UpdateActionName = "Update"; result.ShowBoxHeader = false; result.CancelButtonText = T("Back"); result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml; result.FormWrapperEndHtml = Constants.Form.FormWrapperEndHtml; result.RegisterFileUploadOptions("ImageUrl.FileName", new ControlFileUploadOptions { AllowedExtensions = "jpg,jpeg,png,gif" }); result.RegisterFileUploadOptions("HomeImageUrl.FileName", new ControlFileUploadOptions { AllowedExtensions = "jpg,jpeg,png,gif" }); return(result); }
public ActionResult Update(ProductsGroupModel model) { if (!ModelState.IsValid) { return(new AjaxResult().Alert(T(Constants.Messages.InvalidModel))); } ProductsGroupInfo item = model.Id == 0 ? new ProductsGroupInfo() : service.GetById(model.Id); var alias = item.Alias; if (string.IsNullOrEmpty(alias)) { alias = Utilities.GetAlias(model.GroupName); alias = GetAlias(item.Id, alias, alias); } item.GroupName = model.GroupName; item.Alias = alias; item.ImageUrl = model.ImageUrl; item.HomeImageUrl = model.HomeImageUrl; item.BackgroundImageUrl = model.BackgroundImageUrl; item.Notes = model.Notes; service.Save(item); return(new AjaxResult().NotifyMessage("UPDATE_ENTITY_COMPLETE").Alert(T("Cập nhật thành công."))); }