public ActionResult ColectFlightDataFlight() { var model = new VMDirectFlight(); return(View("ColectFlightDataFlight", model)); }
public ActionResult CheckDirctFlightPost(string FlightNumber, string Date) { // testing Claim c = null; Guid g = new Guid("ecbc3e69-71c0-4fab-971d-3acc3bd98480"); using (AirHelpDBContext dc = new AirHelpDBContext()) { c = dc.Claims.Where(cl => cl.ClaimId == g).SingleOrDefault(); ViewBag.IsEu = c.AirPorts.Any(a => CommonHeppler.IsEuCountry(a.countryCode)); ViewBag.delayMessage = (c.issueDistance < 1500000 ? "Полета ви закъсня ли с повече от 2 часа?" : (c.issueDistance < 3500000 || ViewBag.IsEu ? "Полета ви закъсня ли с повече от 3 часа?" : "Полета ви закъсня ли с повече от 3 часа ?")); } return(View("ColectData", c)); var model = new VMDirectFlight() { date = Date, number = FlightNumber, numberError = "" }; var arr = Date.Split('.'); var day = int.Parse(arr[0]); var mont = int.Parse(arr[1]); var year = int.Parse(arr[2]); FlightStatus fligth = CommonHeppler.GetFlight(FlightNumber, Date); if (fligth.flightStatuses.Length == 0) { model.commonError = "Невалидна комбинция от номер и дата на полета"; return(View("DirectFlight", model)); } var AirLine = fligth.appendix.airlines.ToList().Find(a => a.iata == fligth.flightStatuses[0].primaryCarrierFsCode); Claim claim = new Claim { ClaimId = Guid.NewGuid(), FlightDate = Date, State = ClaimStatus.Accepted, UserId = User.Identity.IsAuthenticated ? User.Identity.Name : null, DateCreated = DateTime.Now, Type = ProblemType.Pending, FlightNumber = FlightNumber, AirCompany = AirLine.name, AirCompanyCountry = "" }; int number = 0; fligth.appendix.airports.ToList().ForEach(a => { double distance = 0; if (number > 0) { var sCoord = new GeoCoordinate(fligth.appendix.airports[number - 1].longitude, fligth.appendix.airports[number - 1].latitude); var eCoord = new GeoCoordinate(fligth.appendix.airports[number].longitude, fligth.appendix.airports[number].latitude); distance = sCoord.GetDistanceTo(eCoord); } AirPort airport = new AirPort { Id = Guid.NewGuid(), ap_name = a.name, city = a.city, cityCode = a.cityCode, country = a.countryName, countryCode = a.countryCode, elevation = a.elevationFeet, iata = a.iata, number = number, name = a.name, timezone = 0, icao = a.icao, type = "", x = a.latitude, y = a.longitude, distanceToNext = distance }; number++; claim.AirPorts.Add(airport); }); claim.allDistance = claim.AirPorts.Sum(a => a.distanceToNext); using (AirHelpDBContext dc = new AirHelpDBContext()) { dc.Claims.Add(claim); dc.SaveChanges(); } return(View("ColectData", claim)); }
public ActionResult DirctFlight() { var model = new VMDirectFlight(); return(View("DirectFlight", model)); }