Esempio n. 1
0
        public JsonResult Manage(SettingTypeModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_settingTypeServices.ManageSettingType(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Manage user group
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the user group model</param>
        /// <returns></returns>
        public ResponseModel ManageSettingType(GridOperationEnums operation, SettingTypeModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<SettingTypeModel, SettingType>();
            SettingType settingType;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    settingType = _settingTypeRepository.GetById(model.Id);
                    settingType.Name = model.Name;
                    settingType.RecordOrder = model.RecordOrder;
                    response = Update(settingType);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::UpdateSuccessfully:::Update setting type successfully.")
                        : _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::UpdateFailure:::Update setting type failed. Please try again later."));

                case GridOperationEnums.Add:
                    settingType = Mapper.Map<SettingTypeModel, SettingType>(model);
                    response = Insert(settingType);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::CreateSuccessfully:::Create setting type successfully.")
                        : _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::CreateFailure:::Create setting type failed. Please try again later."));

                case GridOperationEnums.Del:
                    response = Delete(model.Id);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::DeleteSuccessfully:::Delete setting type successfully.")
                        : _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::DeleteFailure:::Delete setting type failed. Please try again later."));
            }
            return new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::SettingTypes:::Messages:::ObjectNotFounded:::Setting type is not founded.")
            };
        }