public ActionResult Create([Bind(Include = "Name,Quantity")] CreateBeerViewModel model) { if (ModelState.IsValid) { var beer = new Beer { Quantity = model.Quantity, Name = model.Name, Owner = _sessionContext.GetCurrentLoggedUser() }; _persistenceContext.Add(beer); _persistenceContext.SaveChanges(); TempData["messageInfo"] = "Your beer has been added."; return RedirectToAction("Index"); } return View(model); }
public BeerViewModel(Beer beer) { ID = beer.ID; Name = beer.Name; Quantity = beer.Quantity; }