public ActionResult Create(SongRequest songRequest) { if (String.IsNullOrEmpty(songRequest.ArtistName) && String.IsNullOrEmpty(songRequest.SongName)) ModelState.AddModelError("SongName", "Hmmm you've got to give us at least an artist or a song name"); if (ModelState.IsValid) { songRequest.Updated = DateTime.UtcNow; _db.SongRequests.Add(songRequest); _db.SaveChanges(); return RedirectToAction("Index"); } return View(songRequest); }
public ActionResult Edit(SongRequest songRequest) { if (ModelState.IsValid) { songRequest.Updated = DateTime.UtcNow; _db.Entry(songRequest).State = EntityState.Modified; _db.SaveChanges(); return RedirectToAction("Index"); } return View(songRequest); }
public ActionResult Create() { var sr = new SongRequest(); sr.IPAddress = Request.ServerVariables["REMOTE_ADDR"]; return View(sr); }