public ActionResult Create(StallModel stall) { if (ModelState.IsValid) { var repo = new StallRepository(); bool result = repo.SaveNewStall(stall); if (result) { return(RedirectToAction("Details", "Stall")); } } return(View(stall)); }
public bool SaveNewStall(StallModel stall) { if (stall != null) // maybe take out { using (var context = new ShukRoutingContext()) { var Stall = new Stall() { StallID = stall.StallID, StallName = stall.StallName, FirstCoord = stall.FirstCoord, SecondCoord = stall.SecondCoord }; context.Stalls.Add(Stall); context.SaveChanges(); } return(true); } return(false); }
public List <StallModel> GetStallsDetails(string stallName = null) { using (var context = new ShukRoutingContext()) { List <Stall> stalls = new List <Stall>(); if (stallName == null) { stalls = context.Stalls.AsNoTracking() .ToList(); } else { stalls = context.Stalls.AsNoTracking() .Where(s => s.StallName == stallName) .ToList(); } if (stalls != null) { List <StallModel> stallsDisplay = new List <StallModel>(); foreach (var stall in stalls) { var stallDisplay = new StallModel() { StallID = stall.StallID, StallName = stall.StallName, FirstCoord = stall.FirstCoord, SecondCoord = stall.SecondCoord }; stallsDisplay.Add(stallDisplay); } return(stallsDisplay); } return(null); } }