public bool CreateWishlist(WishListCreate model) { var entity = new Wishlist() { OwnerId = _userId, WishListTitle = model.WishListTitle, Toys = model.Toys //CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Wishlist.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(WishListCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateWishlistService(); var toysList = service.GetToysForMultiSelect(); ViewBag.Toys = new MultiSelectList(toysList, "Value", "Text"); if (service.CreateWishlist(model)) { TempData["SaveResult"] = "Neat! Your wishlist was saved."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "DOH! Your wishlist didn't save!"); return(View(model)); }