Ejemplo n.º 1
0
        public ActionResult Edit(LocalizedResourceManageModel model, SubmitType submit)
        {
            if (ModelState.IsValid)
            {
                var response = _localizedResourceService.SaveLocalizedResource(model);
                SetResponseMessage(response);
                if (response.Success)
                {
                    switch (submit)
                    {
                    case SubmitType.Save:
                        return(RedirectToAction("Index", new { languageId = model.LanguageId }));

                    case SubmitType.SaveAndContinueEdit:
                        return(RedirectToAction("Edit", new { id = model.Id }));
                    }
                }
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save localized resource
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveLocalizedResource(LocalizedResourceManageModel model)
        {
            ResponseModel response;
            var           localizedResource = GetById(model.Id);

            if (localizedResource != null)
            {
                localizedResource.LanguageId      = model.LanguageId;
                localizedResource.TextKey         = model.TextKey;
                localizedResource.DefaultValue    = model.DefaultValue;
                localizedResource.TranslatedValue = model.TranslatedValue;
                response = Update(localizedResource);

                //Refresh the dictionary when success updating
                if (response.Success)
                {
                    RefreshDictionary();
                }

                response.SetMessage(response.Success
                    ? T("LocalizedResource_Message_UpdateSuccessfully")
                    : T("LocalizedResource_Message_UpdateFailure"));
            }
            else
            {
                Mapper.CreateMap <LocalizedResourceManageModel, LocalizedResource>();
                localizedResource = Mapper.Map <LocalizedResourceManageModel, LocalizedResource>(model);

                response = Insert(localizedResource);

                //Refresh the dictionary when success creating
                if (response.Success)
                {
                    RefreshDictionary();
                }
                response.SetMessage(response.Success
                    ? T("LocalizedResource_Message_CreateSuccessfully")
                    : T("LocalizedResource_Message_CreateFailure"));
            }
            return(response);
        }
Ejemplo n.º 3
0
        public ActionResult Create(int languageId)
        {
            var localizedResource = new LocalizedResourceManageModel(languageId);

            return(View(localizedResource));
        }