public ActionResult PopupEdit(FileTemplateManageModel model, SubmitType submit) { if (ModelState.IsValid) { var response = _fileTemplateService.SaveFileTemplate(model); SetResponseMessage(response); if (response.Success) { switch (submit) { case SubmitType.PopupSave: return(View("CloseFancyBox", new CloseFancyBoxViewModel { IsReload = false, ReturnUrl = string.Empty })); case SubmitType.SaveAndContinueEdit: return(RedirectToAction("PopupEdit", new { id = model.Id })); } } } SetupPopupAction(); return(View(model)); }
/// <summary> /// Save file template /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel SaveFileTemplate(FileTemplateManageModel model) { ResponseModel response; var fileTemplate = GetById(model.Id); if (fileTemplate != null) { fileTemplate.Name = model.Name; fileTemplate.Action = model.Action; fileTemplate.Controller = model.Controller; fileTemplate.Parameters = model.Parameters; fileTemplate.Area = model.Area; fileTemplate.PageTemplateId = model.PageTemplateId; response = Update(fileTemplate); return(response.SetMessage(response.Success ? T("FileTemplate_Message_UpdateSuccessfully") : T("FileTemplate_Message_UpdateFailure"))); } Mapper.CreateMap <FileTemplateManageModel, FileTemplate>(); fileTemplate = Mapper.Map <FileTemplateManageModel, FileTemplate>(model); response = Insert(fileTemplate); return(response.SetMessage(response.Success ? T("FileTemplate_Message_CreateSuccessfully") : T("FileTemplate_Message_CreateFailure"))); }
/// <summary> /// Save file template /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel SaveFileTemplate(FileTemplateManageModel model) { ResponseModel response; var fileTemplate = GetById(model.Id); if (fileTemplate != null) { fileTemplate.Name = model.Name; fileTemplate.Action = model.Action; fileTemplate.Controller = model.Controller; fileTemplate.Parameters = model.Parameters; fileTemplate.PageTemplateId = model.PageTemplateId; fileTemplate.ParentId = model.ParentId; response = HierarchyUpdate(fileTemplate); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::UpdateSuccessfully:::Update file template successfully.") : _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::UpdateFailure:::Update file template failed. Please try again later."))); } Mapper.CreateMap <FileTemplateManageModel, FileTemplate>(); fileTemplate = Mapper.Map <FileTemplateManageModel, FileTemplate>(model); response = HierarchyInsert(fileTemplate); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::CreateSuccessfully:::Create file template successfully.") : _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::CreateFailure:::Create file template failed. Please try again later."))); }
/// <summary> /// Update file template data /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel UpdateFileTemplateData(XEditableModel model) { var fileTemplate = GetById(model.Pk); if (fileTemplate != null) { var property = ReflectionUtilities.GetAllPropertiesOfType(typeof(FileTemplateManageModel)) .FirstOrDefault(p => p.Name.Equals(model.Name, StringComparison.CurrentCultureIgnoreCase)); if (property != null) { object value = model.Value.ToType(property, WorkContext.CurrentTimezone); #region Validate var manageModel = new FileTemplateManageModel(fileTemplate); manageModel.SetProperty(model.Name, value); var validationResults = manageModel.ValidateModel(); if (validationResults.Any()) { return(new ResponseModel { Success = false, Message = validationResults.BuildValidationMessages() }); } #endregion fileTemplate.SetProperty(model.Name, value); var response = Update(fileTemplate); return(response.SetMessage(response.Success ? T("FileTemplate_Message_UpdateFileTemplateInfoSuccessfully") : T("FileTemplate_Message_UpdateFileTemplateInfoFailure"))); } return(new ResponseModel { Success = false, Message = T("FileTemplate_Message_PropertyNotFound") }); } return(new ResponseModel { Success = false, Message = T("FileTemplate_Message_ObjectNotFound") }); }
public ActionResult Create(FileTemplateManageModel model, SubmitType submit) { if (ModelState.IsValid) { var response = _fileTemplateService.SaveFileTemplate(model); SetResponseMessage(response); if (response.Success) { switch (submit) { case SubmitType.Save: return(RedirectToAction("Index")); default: return(RedirectToAction("Edit", new { id = (int)response.Data })); } } } return(View(model)); }
public ActionResult Edit(FileTemplateManageModel model, SubmitTypeEnums submit) { if (ModelState.IsValid) { var response = _fileTemplateServices.SaveFileTemplate(model); if (response.Success) { SetSuccessMessage(response.Message); switch (submit) { case SubmitTypeEnums.Save: return(RedirectToAction("Index")); default: return(RedirectToAction("Edit", new { id = model.Id })); } } SetErrorMessage(response.Message); } model.PageTemplates = _pageTemplateServices.GetPageTemplateSelectListForFileTemplate(model.Id); model.Parents = _fileTemplateServices.GetPossibleParents(model.Id); return(View(model)); }
public ActionResult Edit(FileTemplateManageModel model, string returnUrl, SubmitType submit) { if (ModelState.IsValid) { var response = _fileTemplateService.SaveFileTemplate(model); SetResponseMessage(response); if (response.Success) { switch (submit) { case SubmitType.Save: if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index")); default: return(RedirectToAction("Edit", new { id = model.Id, returnUrl })); } } } return(View(model)); }