public ActionResult Edit(int id, NuggetViewModel viewModel) { if (ModelState.IsValid) { var nugget = _nuggetService.GetNuggetByID(id); nugget.Description = viewModel.Description; nugget.Title = viewModel.Title; _nuggetService.SaveNugget(nugget); return RedirectToAction("Index", new {id = nugget.ID}); } return View(viewModel); }
public ActionResult Add(NuggetViewModel viewModel, string Tags) { if (ModelState.IsValid) { if (_memberAuthenticationService.LoggedIn) { var newNugget = viewModel.BuildNugget(); newNugget.MemberID = _memberAuthenticationService.LoggedInMember.ID; _nuggetService.SaveNugget(newNugget); _tagsService.AssignTagsByNameToContentType(Tags, newNugget); return RedirectToAction("Index", new {id = newNugget.ID}); } else { ModelState.AddModelError("", "You must be logged in to post a nugget"); } } return View(viewModel); }