public ActionResult Edit(LocalizedResourceModel model, bool continueEditing) { var entity = localizationService.GetResource(model.Id); if (null == entity) { return(RedirectToAction("Index", new { languageId = model.LanguageId })); } if (ModelState.IsValid) { entity = model.MapTo(entity); localizationService.UpdateResource(entity); if (continueEditing) { return(RedirectToAction("Edit", new { id = entity.Id })); } else { return(RedirectToAction("Index", new { languageId = entity.LanguageId })); } } return(View(model)); }
private void PrepareResourceModel(LocalizedResourceModel model, LocalizedResource entity) { if (null != entity) { model = entity.MapTo(model); } }
public ActionResult Add() { var model = new LocalizedResourceModel(); PrepareResourceModel(model, null); return(View(model)); }
public ActionResult Edit(int id) { var model = new LocalizedResourceModel(); var entity = localizationService.GetResource(id); PrepareResourceModel(model, entity); return(View(model)); }
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 })); }
/// <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.") }); }
public ActionResult Add(LocalizedResourceModel model, bool continueEditing) { if (ModelState.IsValid) { var entity = model.MapTo <LocalizedResourceModel, LocalizedResource>(); localizationService.InsertResource(entity); if (continueEditing) { return(RedirectToAction("Add")); } else { return(RedirectToAction("Index", new { languageId = entity.LanguageId })); } } return(View(model)); }