public ActionResult create(SimpleNotification newSimpleNotification) { var newNotification = new Notification(); if (ModelState.IsValid) { var repository = GetRepository<Notification>(); var player = GetPlayer(); //from form newNotification.Subject = newSimpleNotification.Subject; newNotification.Body = newSimpleNotification.Body; //set up notification newNotification.Created = DateTime.Now; newNotification.Updated = newNotification.Created; newNotification.Live = true; newNotification.Player = player; newNotification.NotificationType = (int)SiteHelper.NotificationType.BPL; repository.Add(newNotification); return Redirect("/notification"); } return View(newSimpleNotification); }
public ActionResult edit(int id, SimpleNotification editSimpleNotification) { if (ModelState.IsValid) { var repository = GetRepository<Notification>(); var dbNotification = repository.Get(id); //from form dbNotification.Subject = editSimpleNotification.Subject; dbNotification.Body = editSimpleNotification.Body; //only thing to update is the updated value(subject/body done above) dbNotification.Updated = DateTime.Now; //don't change the original poster //dbNotification.Player = player; repository.Add(dbNotification); return Redirect("/notification"); } return View("Create", editSimpleNotification); }