public void DeleteSchedule(int id) { AirlineSchedules obj = ent.AirlineSchedules.Where(x => x.ScheduleId == id).FirstOrDefault(); ent.DeleteObject(obj); ent.SaveChanges(); }
public void AddAirLineSchedule(AirlineSchedules obj) { EntityModel ent = new EntityModel(); ent.AddToAirlineSchedules(obj); ent.SaveChanges(); }
public void EditAirLineSchedule(AirlineSchedules obj) { EntityModel ent = new EntityModel(); var result = ent.AirlineSchedules.Where(x => x.ScheduleId == obj.ScheduleId).FirstOrDefault(); if (result != null) { ent.ApplyCurrentValues(result.EntityKey.EntitySetName, obj); ent.SaveChanges(); } }
public ActionResult Edit(Int32 id) { ViewData["AirLinelist"] = ent.Airlines.Where(x => x.AirlineTypeId == 2).ToList(); ViewData["DepartureCityList"] = ent.AirlineCities.Where(x => x.AirlineCityTypeId == 2).ToList(); ViewData["DestinationCityList"] = ent.AirlineCities.Where(x => x.AirlineCityTypeId == 2).ToList(); AirlineSchedules airSchedule = new AirlineSchedules(); TimeSpan departureTime = airSchedule.DepartureTime; var model = ser.getAirLineScheduleById(id); //var model = ser.GetAirLineScheduleById(id); return(View(model)); }
public ActionResult Create() { ViewData["AirLinelist"] = ent.Airlines.Where(x => x.AirlineTypeId == 2).ToList(); ViewData["DepartureCityList"] = new SelectList(ent.AirlineCities.Where(x => x.AirlineCityTypeId == 2).OrderBy(x => x.CityName).ToList(), "CityID", "CityName"); //ViewData["DestinationCityList"] = new SelectList(ent.AirlineCities.Where(x => x.AirlineCityTypeId == 2).ToList(), "CityID", "CityName"); AirlineSchedules airSchedule = new AirlineSchedules(); TimeSpan departureTime = airSchedule.DepartureTime; //TimeSpan arrivalTime = airSchedule.ArrivalTime; return(View()); }
public void addAirLineSchedule(AirLineScheduleModel obj) { AirlineSchedules model = new AirlineSchedules { AirlineId = obj.AirlineId, DepartureCityId = obj.DepartureCityId, ArrivalTime = obj.ArrivalTime, DepartureTime = obj.DepartureTime, FlightNumber = obj.FlightNumber, Fare = obj.Fare, DestinationCityId = obj.DestinationCityId, ScheduleId = obj.ScheduleId, Sunday = obj.Sunday, Monday = obj.Monday, Tuesday = obj.Tuesday, Wednesday = obj.Wednesday, Thrusday = obj.Thursday, Friday = obj.Friday, Saturday = obj.Saturday }; ent.AddToAirlineSchedules(model); ent.SaveChanges(); }
public ActionResult Edit(AirLineScheduleModel model, Int32 id, string[] days) { if (days != null) { for (int i = 0; i < days.Length; i++) { if (days[i] == "1") { model.Sunday = true; } else if (days[i] == "2") { model.Monday = true; } else if (days[i] == "3") { model.Tuesday = true; } else if (days[i] == "4") { model.Wednesday = true; } else if (days[i] == "5") { model.Thursday = true; } else if (days[i] == "6") { model.Friday = true; } else if (days[i] == "7") { model.Saturday = true; } } } else { TempData["Days"] = "Please Select the Date(s)"; ModelState.AddModelError("Days", "please Select the Date(s)"); } if (ser.CheckCities(model.DepartureCityId, model.DestinationCityId) == false) { TempData["Cities"] = "Please Check the Cities"; ModelState.AddModelError("Cities", "Please Check the Cities"); } if (ser.CheckTime(model.DepartureTime, model.ArrivalTime) == false) { TempData["Time"] = "Please Check the Time"; ModelState.AddModelError("Time", "Please Check the Time"); } if (model.Sunday == false || model.Monday == false || model.Tuesday == false || model.Wednesday == false || model.Thursday == false || model.Friday == false || model.Saturday == false) { TempData["Days"] = "Please Select the Date(s)"; ModelState.AddModelError("Days", "please Select the Date(s)"); } ViewData["AirLinelist"] = ent.Airlines.Where(x => x.AirlineTypeId == 2).ToList(); ViewData["DepartureCityList"] = ent.AirlineCities.Where(x => x.AirlineCityTypeId == 2).ToList(); ViewData["DestinationCityList"] = ent.AirlineCities.Where(x => x.AirlineCityTypeId == 2).ToList(); if (this.ModelState.IsValid) { AirlineSchedules obj = new AirlineSchedules(); obj.ScheduleId = id; obj.AirlineId = model.AirlineId; obj.DepartureCityId = model.DepartureCityId; obj.DestinationCityId = model.DestinationCityId; obj.FlightNumber = model.FlightNumber; obj.Sunday = model.Sunday; obj.Monday = model.Monday; obj.Tuesday = model.Tuesday; obj.Wednesday = model.Wednesday; obj.Thrusday = model.Thursday; obj.Friday = model.Friday; obj.Saturday = model.Saturday; obj.DepartureTime = model.DepartureTime; obj.ArrivalTime = model.ArrivalTime; obj.Fare = model.Fare; ser.EditAirLineSchedule(obj); return(RedirectToAction("Index")); } return(View(model)); }