public ActionResult Edit(Guid id, OutcomeViewModel model) { var outcomeToEdit = RepositoryFactory.OutcomeRepository.GetNullableById(id); if (outcomeToEdit == null) { return(RedirectToAction("Index")); } outcomeToEdit.Name = model.Name; if (ModelState.IsValid) { if (model.File != null) //replace file if we have a new one { var badgeImage = _fileService.Save(model.File, publicAccess: true); outcomeToEdit.ImageUrl = badgeImage.Uri.AbsoluteUri; } RepositoryFactory.OutcomeRepository.EnsurePersistent(outcomeToEdit); Message = "Outcome Edited Successfully"; return(RedirectToAction("Index")); } else { var viewModel = OutcomeViewModel.Create(Repository); viewModel.Name = model.Name; viewModel.Name = model.Description; return(View(viewModel)); } }
public ActionResult Create(OutcomeViewModel model) { var outcomeToCreate = new Outcome { Name = model.Name, Description = model.Description }; var outcomeImage = _fileService.Save(model.File, publicAccess: true); outcomeToCreate.ImageUrl = outcomeImage.Uri.AbsoluteUri; if (ModelState.IsValid) { RepositoryFactory.OutcomeRepository.EnsurePersistent(outcomeToCreate); Message = "Outcome Created Successfully"; return(RedirectToAction("Index")); } else { var viewModel = OutcomeViewModel.Create(Repository); viewModel.Name = model.Name; viewModel.Description = model.Description; return(View(viewModel)); } }
// // GET: /Admin/Outcome/Edit/5 public ActionResult Edit(Guid id) { var outcome = RepositoryFactory.OutcomeRepository.GetNullableById(id); if (outcome == null) { return(RedirectToAction("Index")); } var viewModel = OutcomeViewModel.Create(Repository); viewModel.Name = outcome.Name; viewModel.Description = outcome.Description; viewModel.ImageUrl = outcome.ImageUrl; return(View(viewModel)); }
// // GET: /Admin/Outcome/Create public ActionResult Create() { var viewModel = OutcomeViewModel.Create(Repository); return(View(viewModel)); }