public object Create(Album album) { try { album.ReleaseDate = DateTime.Now; db.Albums.Add(album); db.SaveChanges(); return JsonConvert.SerializeObject( new { Result = "Ok", Record = album }); } catch (Exception e) { return JsonConvert.SerializeObject( new { Result = "False", Message = e.Message }); } }
public object Create(Album album) { try { if (db.Albums.Any(a => a.Artist == album.Artist && a.Title==album.Title )) { return JsonConvert.SerializeObject(new { Result = "Double", Message = "Already Exists" }); } else { db.Albums.Add(album); db.SaveChanges(); return JsonConvert.SerializeObject(new { Result = "OK", Record = album }); } } catch(Exception e) { return JsonConvert.SerializeObject (new { Result = "Failed", Message=e.Message }); } }
public ActionResult CreateAlbum(Album album) { db.Albums.Add(album); db.SaveChanges(); return Redirect("Index"); // return View(); }
public ActionResult CreateAlbum(Album album) { db.Albums.Add(album); db.SaveChanges(); return View(); }