Ejemplo n.º 1
0
        /// <summary>
        /// Manage Site Setting
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the page template model</param>
        /// <returns></returns>
        public ResponseModel ManagePageTemplate(GridOperationEnums operation, PageTemplateModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<PageTemplateModel, PageTemplate>();
            PageTemplate pageTemplate;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    pageTemplate = GetById(model.Id);
                    pageTemplate.Name = model.Name;
                    pageTemplate.ParentId = model.ParentName.ToNullableInt();

                    response = HierarchyUpdate(pageTemplate);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::UpdateSuccessfully:::Update page template successfully.")
                        : _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::UpdateFailure:::Update page template failed. Please try again later."));

                case GridOperationEnums.Add:
                    pageTemplate = Mapper.Map<PageTemplateModel, PageTemplate>(model);
                    pageTemplate.ParentId = model.ParentName.ToNullableInt();
                    pageTemplate.Content = Configurations.CurlyBracketRenderBody;
                    response = HierarchyInsert(pageTemplate);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::CreateSuccessfully:::Create page template successfully.")
                        : _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::CreateFailure:::Create page template failed. Please try again later."));

                case GridOperationEnums.Del:
                    response = Delete(model.Id);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::DeleteSuccessfully:::Delete page template successfully.")
                        : _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::DeleteFailure:::Delete page template failed. Please try again later."));
            }
            return new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::PageTemplates:::Messages:::ObjectNotFounded:::Page template is not founded.")
            };
        }
Ejemplo n.º 2
0
        public JsonResult Manage(PageTemplateModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_pageTemplateServices.ManagePageTemplate(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }