public JsonResult Manage(LocalizedResourceModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(LocalizedResourceServices.ManageLocalizedResource(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Manage LocalizedResource
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel ManageLocalizedResource(GridOperationEnums operation, LocalizedResourceModel model)
        {
            ResponseModel response;
            Mapper.CreateMap<LocalizedResourceModel, LocalizedResource>();
            LocalizedResource localizedResource;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    localizedResource = GetById(model.Id);
                    localizedResource.TranslatedValue = model.TranslatedValue;
                    localizedResource.RecordActive = model.RecordActive;

                    response = Update(localizedResource);
                    if (response.Success)
                        RefreshDictionary();
                    return response.SetMessage(response.Success ?
                        T("AdminModule:::LocalizedResources:::Messages:::UpdateSuccessfully:::Update localized resource successfully.")
                        : T("AdminModule:::LocalizedResources:::Messages:::UpdateFailure:::Update localized resource failed. Please try again later."));

                case GridOperationEnums.Add:
                    localizedResource = Mapper.Map<LocalizedResourceModel, LocalizedResource>(model);
                    localizedResource.DefaultValue = model.TranslatedValue;
                    response = Insert(localizedResource);
                    if (response.Success)
                        RefreshDictionary();
                    return response.SetMessage(response.Success ?
                        T("AdminModule:::LocalizedResources:::Messages:::CreateSuccessfully:::Create localized resource successfully.")
                        : T("AdminModule:::LocalizedResources:::Messages:::CreateFailure:::Create localized resource failed. Please try again later."));

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