public ActionResult AddNew() { ViewBag.Message = "Add a new garage sale event"; SaleModel model = new SaleModel(); return View(model); }
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); }
public ActionResult Confirm(SaleModel model) { return View(model); }
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; }