Esempio n. 1
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var state = new State
             {
                 StateID   = 10,
                 StateAbbr = "Fl"
             };
             BreweryViewModel brewery = new BreweryViewModel
             {
                 BreweryID     = id,
                 Name          = collection["Name"],
                 Description   = collection["Description"],
                 ImageURL      = collection["ImageURL"],
                 Address       = collection["Address"],
                 ZipCode       = collection["ZipCode"],
                 StateID       = 10, //They should only be able to pick florida right now. Maybe still show the text field but make it uneditable
                 PhoneNumber   = collection["PhoneNumber"],
                 BusinessHours = collection["BusinessHours"],
                 HasTShirt     = Convert.ToBoolean(collection["HasTShirt"].Split(',')[0]),
                 HasMug        = Convert.ToBoolean(collection["HasMug"].Split(',')[0]),
                 HasGrowler    = Convert.ToBoolean(collection["HasGrowler"].Split(',')[0]),
                 HasFood       = Convert.ToBoolean(collection["HasFood"].Split(',')[0]),
                 State         = state
             };
             logic.PutBrewery(brewery);
             return(RedirectToAction("Breweries"));
         }
         catch (Exception e)
         {
             return(View("Caught Exception"));
         }
     }
     else
     {
         return(View("Invalid Model State"));
     }
 }