public bool CreatePlayList(PlayListCreate model) { var entity = new PlayList() { OwnerId = _userId, Artist = model.Artist, Song = model.Song, Genre = model.Genre, Youtube = model.Youtube, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.PlayLists.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(PlayListCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePlayListService(); if (service.CreatePlayList(model)) { TempData["SaveResult"] = "Your note was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "playlist could not be created."); return(View(model)); }