コード例 #1
0
        public ActionResult AddNew()
        {
            ViewBag.Message = "Add a new garage sale event";

            SaleModel model = new SaleModel();
            return View(model);
        }
コード例 #2
0
        public ActionResult AddNew(SaleModel model)
        {
            if (ModelState.IsValid)
            {
                SaleService salesService = new SaleService();
                Sale newSale = salesService.GetNewSale();

                MapSaleModelToSale(model, newSale, true);

                if (salesService.SaveNewSale(newSale))
                {
                    model = MapSaleToSaleModel(newSale);
                    return View("Confirm", model);
                }
                else
                {
                    ModelState.AddModelError("", "Could not save sale details.");
                }
            }
            else
            {
                ModelState.AddModelError("", "Sale event details are not correct.");
            }

            return View(model);
        }
コード例 #3
0
 public ActionResult Confirm(SaleModel model)
 {
     return View(model);
 }
コード例 #4
0
 private void MapSaleModelToSale(SaleModel vItem, Sale newSale, bool vIsNew)
 {
     if (!vIsNew)
     {
         newSale.Id = vItem.Id;
     }
     newSale.Title = vItem.Title;
     newSale.Description = vItem.Description;
     newSale.Address = vItem.Address;
     newSale.LatLong = "10000,20000";//			vItem.LatLong;
     newSale.SaleDate = vItem.SaleDate;
     newSale.LinkUrl = vItem.LinkUrl;
 }