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); }
/// <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.")); }