コード例 #1
0
        /// <summary>
        /// Manage Site Setting
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the file template model</param>
        /// <returns></returns>
        public ResponseModel ManageFileTemplate(GridOperationEnums operation, FileTemplateModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<FileTemplateModel, FileTemplate>();
            FileTemplate fileTemplate;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    fileTemplate = GetById(model.Id);
                    fileTemplate.Name = model.Name;
                    fileTemplate.Controller = model.Controller;
                    fileTemplate.Action = model.Action;
                    fileTemplate.Parameters = model.Parameters;
                    fileTemplate.ParentId = model.ParentName.ToNullableInt();
                    fileTemplate.PageTemplateId = model.PageTemplateName.ToNullableInt();

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

                case GridOperationEnums.Add:
                    fileTemplate = Mapper.Map<FileTemplateModel, FileTemplate>(model);
                    fileTemplate.ParentId = model.ParentName.ToNullableInt();
                    fileTemplate.PageTemplateId = model.PageTemplateName.ToNullableInt();
                    response = HierarchyInsert(fileTemplate);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::CreateSuccessfully:::Create file template successfully.")
                        : _localizedResourceServices.T("AdminModule:::FileTemplate:::Messagess:::CreateFailure:::Insert file template failed. Please try again later."));

                case GridOperationEnums.Del:
                    response = Delete(model.Id);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::DeleteSuccessfully:::Messages:::Delete file template successfully.")
                        : _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::DeleteFailure:::Delete file template failed. Please try again later."));
            }
            return new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::FileTemplates:::Messages:::ObjectNotFounded:::File template is not founded.")
            };
        }
コード例 #2
0
        public JsonResult Manage(FileTemplateModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_fileTemplateServices.ManageFileTemplate(manageModel.Operation, model));
            }

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