Ejemplo n.º 1
0
        public JsonResult Manage(LanguageModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_languageServices.ManageLanguage(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Manage Language
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel ManageLanguage(GridOperationEnums operation, LanguageModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<LanguageModel, Language>();
            Language language;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    language = GetById(model.Id);
                    language.Name = model.Name;
                    language.ShortName = model.ShortName;
                    language.RecordActive = model.RecordActive;
                    language.RecordOrder = model.RecordOrder;
                    response = Update(language);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::Languages:::Messages::UpdateSuccessfully:::Update language successfully.")
                        : _localizedResourceServices.T("AdminModule:::Languages:::Messages:::UpdateFailure:::Update language failed. Please try again later."));

                case GridOperationEnums.Add:
                    language = Mapper.Map<LanguageModel, Language>(model);
                    response = Insert(language);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::Languages:::Messages:::CreateSuccessfully:::Create language successfully.")
                        : _localizedResourceServices.T("AdminModule:::Languages:::Messages:::CreateFailure:::Create language failed. Please try again later."));

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