public ActionResult Edit(int id) { WorkContext.Breadcrumbs.Add(new Breadcrumb { Text = T("Quản lý cửa hàng phân phối"), Url = "#" }); WorkContext.Breadcrumbs.Add(new Breadcrumb { Text = T("Thông tin cửa hàng phân phối"), Url = Url.Action("Index") }); var model = new StoreBranchModel(); if (id > 0) { model = this.service.GetById(id); } var result = new ControlFormResult <StoreBranchModel>(model); result.Title = this.T("Thông tin cửa hàng phân phối"); result.FormMethod = FormMethod.Post; result.UpdateActionName = "Update"; result.ShowCancelButton = false; result.ShowBoxHeader = false; result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml; result.FormWrapperEndHtml = Constants.Form.FormWrapperEndHtml; result.RegisterFileUploadOptions("LogoUrl.FileName", new ControlFileUploadOptions { AllowedExtensions = "jpg,jpeg,png,gif" }); 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(StoreBranchModel model) { if (!ModelState.IsValid) { return(new AjaxResult().Alert(T(Constants.Messages.InvalidModel))); } StoreBranchInfo item = model.Id == 0 ? new StoreBranchInfo() : service.GetById(model.Id); item.Name = model.Name; item.Address = model.Address; item.PhoneNumber = model.PhoneNumber; item.Notes = model.Notes; item.LogoUrl = model.LogoUrl; service.Save(item); return(new AjaxResult().NotifyMessage("UPDATE_ENTITY_COMPLETE").Alert(T("Cập nhật thành công."))); }