コード例 #1
0
        /// <summary>
        /// Update a brewery
        /// </summary>
        /// <param name="brewery">int ID of brewery</param>
        public void Update(Brewery brewery)
        {
            var index = this.breweries.FindIndex(a => a.ID == brewery.ID);

            if (index != -1) this.breweries[index] = brewery;
            else throw new ArgumentException("BreweryNotFound");
        }
コード例 #2
0
        public ActionResult CreateBrewery(FormCollection form)
        {
            if (form["operation"] == "Add")
            {
                Brewery newBrewery = new Brewery()
                {
                    ID = br.GetNextID(),
                    Name = form["name"],
                    Address = form["address"],
                    City = form["city"],
                    State = (AppEnum.StateAbrv)Enum.Parse(typeof(AppEnum.StateAbrv), form["state"]),
                    Zip = form["zip"],
                    Phone = form["phone"]
                };

                br.Insert(newBrewery);
            }

            return Redirect("/Breweries/ShowTable");
        }
コード例 #3
0
        public ActionResult CreateBrewery(FormCollection form)
        {
            if (form["operation"] == "Create")
            {
                List<Brewery> breweries = (List<Brewery>)Session["Breweries"];

                Brewery newBrewery = new Brewery()
                {
                    ID = GetNextID(),
                    Name = form["name"],
                    Address = form["address"],
                    City = form["city"],
                    State = (AppEnum.StateAbrv)Enum.Parse(typeof(AppEnum.StateAbrv), form["state"]),
                    Zip = form["zip"],
                    Phone = form["phone"]
                };

                breweries.Add(newBrewery);

                Session["Breweries"] = breweries;
            }

            return RedirectToAction("ShowTable");
        }
コード例 #4
0
        public ActionResult UpdateBrewery(FormCollection form)
        {
            if (form["operation"] == "Edit")
            {
                Brewery updatedBrewery = new Brewery()
                {
                    ID = Convert.ToInt32(form["ID"]),
                    Name = form["Name"],
                    Address = form["Address"],
                    City = form["City"],
                    State = (AppEnum.StateAbrv)Enum.Parse(typeof(AppEnum.StateAbrv), form["State"]),
                    Zip = form["Zip"],
                    Phone = form["Phone"]
                };

                br.Update(updatedBrewery);
            }

            return Redirect("/Breweries/ShowTable");
        }
コード例 #5
0
 /// <summary>
 /// Add a new brewery
 /// </summary>
 /// <param name="brewery">object Brewery</param>
 public void Insert(Brewery brewery)
 {
     this.breweries.Add(brewery);
 }