Пример #1
0
        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);
        }
Пример #2
0
 public BeerViewModel(Beer beer)
 {
     ID = beer.ID;
     Name = beer.Name;
     Quantity = beer.Quantity;
 }