Ejemplo n.º 1
0
        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

                });
            }
        }
Ejemplo n.º 2
0
        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
                });
            }
        }
Ejemplo n.º 3
0
        public ActionResult CreateAlbum(Album album)
        {
            db.Albums.Add(album);
            db.SaveChanges();
            return Redirect("Index");

               // return View();
        }
Ejemplo n.º 4
0
 public ActionResult CreateAlbum(Album album)
 {
     db.Albums.Add(album);
     db.SaveChanges();
     return View();
 }