public ActionResult Create() { ResourceEditModel viewModel = new ResourceEditModel { Row = new Resources(), Resources = MakeList() }; return(View("Edit", viewModel)); }
public ActionResult Edit(Resources row) { if (ModelState.IsValid) { if (Save(row)) { TempData["message"] = row.Name + " has been saved."; } return(RedirectToAction("Index")); } else // Validation error, so redisplay same view { var model = new ResourceEditModel(); model.Row = row; return(View(model)); } }
public ActionResult Edit(int Id) { try { ResourceEditModel viewModel = new ResourceEditModel { Row = swdb.Resources.First(x => x.Id == Id), Resources = MakeList() }; return(View(viewModel)); } catch (Exception ex) { TempData["message"] = ex.Message; } return(RedirectToAction("Index")); }
public async Task <IActionResult> OnGetAsync() { var entity = await _resManager.GetResourceAsync <XDbResource>(x => x.ID == ID); if (entity == null) { TempData.Warning("Resource not found!"); return(RedirectToPage("Index")); } InputModel = new ResourceEditModel { Key = entity.Key }; return(Page()); }
public IActionResult EditResource(ResourceEditModel model) { model.Update(); if (ModelState.IsValid) { using (var uow = _localizationDataService.StartUnitOfWork()) { var existing = uow.ResourceRepository.Get(model.Id); existing.ResourceKey = model.Name; existing.Author = model.Author; uow.ResourceRepository.Update(existing); uow.Commit(); model.UpdateSuccess(); } } return(View(model)); }