예제 #1
0
        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);
        }
예제 #2
0
 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);
 }
예제 #3
0
 public ActionResult Create()
 {
     var sr = new SongRequest();
     sr.IPAddress = Request.ServerVariables["REMOTE_ADDR"];
     return View(sr);
 }