private IEnumerable <dynamic> GetRacers() { using (var f1Context = new Formula1Entities()) { return(GetRacers(f1Context).Skip(_currentPage * PageSize).Take(PageSize).ToList()); } }
public ActionResult SaveWheelChanges(Wheel UpdatedWheel) { //0. validation if (!ModelState.IsValid) { //over errors for each field in mobdel foreach (ModelState S in ModelState.Values) { //individual errors for each fields } //Request.UserHostAddress return(View("../Shared/Error")); //error page } //1. orm Formula1Entities FOrm = new Formula1Entities(); //find FOrm.Entry(FOrm.Wheels.Find(UpdatedWheel.WheelID)).CurrentValues.SetValues(UpdatedWheel); //save FOrm.SaveChanges(); //go to customer view (refresh customer data) return(RedirectToAction("WheelInventory")); }
private IEnumerable <F1RaceResult> GetResults() { using (var f1Context = new Formula1Entities()) { return(GetRaceResults(f1Context).ToList()); } }
public ActionResult WheelInventory() { Formula1Entities FOrm = new Formula1Entities(); ViewBag.WheelList = FOrm.Wheels.ToList(); return(View("WheelInventoryView")); }
public ActionResult EngineInventory() { Formula1Entities FOrm = new Formula1Entities(); ViewBag.EngineList = FOrm.Engines.ToList(); return(View("EngineInventoryView")); }
private IEnumerable <F1RaceResult> GetRaceResults(Formula1Entities f1Context) => from raceResult in f1Context.RaceResults where raceResult.Race.Date == Date select new F1RaceResult { Position = raceResult.Position, Racer = raceResult.Racer.FirstName + " " + raceResult.Racer.LastName, Car = f1Context.Teams.FirstOrDefault(team => team.Id == raceResult.TeamId).Name };
private static IQueryable <dynamic> GetRacers(Formula1Entities f1Context) => from race in f1Context.Races from raceResult in race.RaceResults orderby race.Date ascending select new { race.Date.Year, race.Circuit.Country, raceResult.Position, Racer = raceResult.Racer.FirstName + " " + raceResult.Racer.LastName, Car = f1Context.Teams.FirstOrDefault(team => team.Id == raceResult.TeamId).Name };
public ActionResult AddNewWheel(Wheel newWheel, int WheelID, float Price) { Formula1Entities FOrm = new Formula1Entities(); FOrm.Wheels.Add(newWheel); FOrm.SaveChanges(); ViewBag.WheelID = WheelID; ViewBag.WCost = Price; return(View("WheelReview")); }
//[HttpPost] public ActionResult AddNewEngine(Engine newEngine, int EngineID, float Price) { Formula1Entities FOrm = new Formula1Entities(); FOrm.Engines.Add(newEngine); FOrm.SaveChanges(); ViewBag.EngineID = EngineID; ViewBag.ECost = Price; return(View("EngineReview")); }
public ActionResult UpdateWheelById(int WheelID) { //1. orm Formula1Entities FOrm = new Formula1Entities(); //find Wheel ToBeUpdated = FOrm.Wheels.Find(WheelID); ViewBag.WheelToBeUpdated = ToBeUpdated; return(View("UpdateWheelView")); }
public ActionResult UpdateEngineById(int EngineID) { //1. orm Formula1Entities FOrm = new Formula1Entities(); //find Engine ToBeUpdated = FOrm.Engines.Find(EngineID); ViewBag.EngineToBeUpdated = ToBeUpdated; return(View("UpdateEngineView")); }
private static List <Championship> GetYears() { using (var f1Context = new Formula1Entities()) { return (f1Context.Races.Select(race => new Championship { Year = race.Date.Year }) .Distinct() .OrderBy(championship => championship.Year) .ToList()); } }
private IEnumerable <F1Race> GetRaces() { using (var f1Context = new Formula1Entities()) { return ((from race in f1Context.Races where race.Date.Year == Year orderby race.Date select new F1Race { Date = race.Date, Country = race.Circuit.Country }).ToList()); } }
public ActionResult DeleteWheelById(int WheelID) { //1. orm Formula1Entities FOrm = new Formula1Entities(); //2. find what you're looking for THEN remove from list //if record has dependencis then delete that first! FOrm.Wheels.Remove((FOrm.Wheels.Find(WheelID))); //save changes FOrm.SaveChanges(); //show new refreshed database return(RedirectToAction("WheelInventory")); }
public IEnumerable <dynamic> GetRaces(int aPage, int aPageSize) { using (var f1Context = new Formula1Entities()) { if (_lastPageSearched == aPage) { return(_cache); } _lastPageSearched = aPage; var dynQuery = GetRaces(f1Context).Skip(aPage * aPageSize).Take(aPageSize); _cache = dynQuery.ToList(); return(_cache); } }