public ActionResult Edit(BreweryViewModel brewery)
        {
            if (ModelState.IsValid)
            {
                var beerFacade = new BreweryFacade();
                beerFacade.Update(brewery);

                return View();
            }
            else
            {
                throw new Exception("Invalid Model State");
            }
        }
Beispiel #2
0
        public bool Update(BreweryViewModel b)
        {
            using (var context = new BeerBoutiqueEntities())
            {
                var brewery = (from x in context.Breweries
                               where x.ID == b.ID
                               select x).FirstOrDefault();

                if (brewery == null)
                    return false;

                brewery.Description = b.Description;
                brewery.Name = b.Name;
                brewery.Contact.Address.Locality = b.Locality;
                brewery.Contact.Address.Region = b.Region;
                brewery.Contact.Phone = b.Phone;
                brewery.Contact.Website = b.Uri;
                context.SaveChanges();
                return true;
            }
        }