public static IList <EmptyLegOffer> GetEmptyLegBids(EmptyLeg el) { ICriteria cr = NHibernateHelper.GetCurrentSession().CreateCriteria(typeof(EmptyLegOffer)); cr.Add(Restrictions.Eq("EmptyLeg", el)); cr.AddOrder(new Order("TimeOfOffer", false)); return(cr.List <EmptyLegOffer>()); }
public static String gmapstring(EmptyLeg el) { String gmapstr = "http://maps.google.com/staticmap?size=300x300&maptype=mobile"; String markers = "&markers="; String path = "&path=rgba:0xff0000ff,weight:5|"; String key = "&key=ABQIAAAAgl32QoKG04P1ZBxYDdc1YxT9aaJEI2oRHrowRn4qpFJKIjABURRW3mkNQMqsNbL-SdLh7ZEILTSnhQ"; // put key here markers += el.Source.GetLattitudeDecimal() + "," + el.Source.GetLongitudeDecimal() + ",blues"; path += el.Source.GetLattitudeDecimal() + "," + el.Source.GetLongitudeDecimal(); markers += "|"; path += "|"; markers += el.Destination.GetLattitudeDecimal() + "," + el.Destination.GetLongitudeDecimal() + ",blues"; path += el.Destination.GetLattitudeDecimal() + "," + el.Destination.GetLongitudeDecimal(); gmapstr = gmapstr + markers + path + key; return(gmapstr); }
public ServiceOperationResult <EmptyLeg> Create(Guid aircraftId, byte direction, int departureAirportId, int arrivalAirportId, DateTime departureDate, DateTime?returnDate, decimal exclusiveCost) { using (FlyJetsDbContext dbContext = new FlyJetsDbContext(_config)) { ServiceOperationResult <EmptyLeg> result = new ServiceOperationResult <EmptyLeg>(); result.IsSuccessfull = true; var departure = _locationService.GetLocation(departureAirportId); var arrival = _locationService.GetLocation(arrivalAirportId); var distance = Utilities.GetDistance(departure.Lat.Value, departure.Lng.Value, arrival.Lat.Value, arrival.Lng.Value); var aircraftSpeed = (from aircraft in dbContext.Aircrafts where aircraft.Id == aircraftId select aircraft.Speed) .First(); var duration = FlightService.CalculateFlightDuration(distance, aircraftSpeed); EmptyLeg emptyLeg = new EmptyLeg() { Id = Guid.NewGuid(), AircraftId = aircraftId, Direction = direction, DepartureAirportId = departureAirportId, ArrivalAirportId = arrivalAirportId, DepartureDate = departureDate, ReturnDate = returnDate, ExclusiveCost = exclusiveCost, Distance = distance, Duration = duration, CreatedById = _accountId, CreatedOn = DateTime.UtcNow, Available = true }; dbContext.EmptyLegs.Add(emptyLeg); dbContext.SaveChanges(); result.Item = emptyLeg; return(result); } }
public ServiceOperationResult <EmptyLeg> Update(Guid emptyLegId, Guid aircraftId, byte direction, int departureAirportId, int arrivalAirportId, DateTime departureDate, DateTime?returnDate, decimal exclusiveCost) { using (FlyJetsDbContext dbContext = new FlyJetsDbContext(_config)) { ServiceOperationResult <EmptyLeg> result = new ServiceOperationResult <EmptyLeg>(); result.IsSuccessfull = true; var departure = _locationService.GetLocation(departureAirportId); var arrival = _locationService.GetLocation(arrivalAirportId); var distance = Utilities.GetDistance(departure.Lat.Value, departure.Lng.Value, arrival.Lat.Value, arrival.Lng.Value) / 1852; var aircraftSpeed = (from aircraft in dbContext.Aircrafts where aircraft.Id == aircraftId select aircraft.Speed) .First(); var duration = FlightService.CalculateFlightDuration(distance, aircraftSpeed); EmptyLeg emptyLeg = dbContext.EmptyLegs .First(el => el.Id == emptyLegId); emptyLeg.AircraftId = aircraftId; emptyLeg.Direction = direction; emptyLeg.DepartureAirportId = departureAirportId; emptyLeg.ArrivalAirportId = arrivalAirportId; emptyLeg.DepartureDate = departureDate; emptyLeg.ReturnDate = returnDate; emptyLeg.ExclusiveCost = exclusiveCost; emptyLeg.Distance = distance; emptyLeg.Duration = duration; dbContext.SaveChanges(); result.Item = emptyLeg; return(result); } }
protected void Page_Load(object sender, EventArgs e) { Customer c = CustomerBO.GetLoggedInCustomer(); if (Request.Params.Get("withdrawbid") != null) { EmptyLegOffer elo = BookRequestDAO.FindEmptyLegOfferByID(Int64.Parse(Request.Params.Get("eloid"))); if (elo.Customer.Equals(c)) { elo.Status = 2; BookRequestDAO.MakePersistent(elo); EmailBO em = new EmailBO("EmptyLegOfferWithdrawNotificationToOperator", Session["Country"].ToString()); em.SendEmailToOperator(elo.EmptyLeg.Aircraft.Vendor); Response.Redirect("EmptyLeg.aspx?eid=" + elo.EmptyLeg.ID); } } if (Request.Params.Get("withdrawaccepted") != null) { EmptyLeg el = BookRequestDAO.FindEmptyLegByID(Int64.Parse(Request.Params.Get("eid"))); if (el.AcceptedOffer.Customer.Equals(c)) { el.AcceptedOffer.Status = 2; BookRequestDAO.MakePersistent(el.AcceptedOffer); el.AcceptedOffer = null; BookRequestDAO.MakePersistent(el); EmailBO em = new EmailBO("EmptyLegAcceptedWithdrawNotificationToOperator", Session["Country"].ToString()); em.SendEmailToOperator(el.Aircraft.Vendor); Response.Redirect("EmptyLeg.aspx?eid=" + el.ID); } } if (Request.Params.Get("acceptoffer") != null) { EmptyLeg el = BookRequestDAO.FindEmptyLegByID(Int64.Parse(Request.Params.Get("eid"))); if (el.AcceptedOffer == null) { EmptyLegOffer elo = new EmptyLegOffer(); elo.EmptyLeg = el; elo.Currency = el.Currency; elo.Status = 1; elo.TimeOfOffer = DateTime.Now; el.AcceptedOffer = elo; elo.IsAgent = false; elo.Customer = CustomerBO.GetLoggedInCustomer(); elo.BidAmount = el.OfferPrice; elo.Agent = null; BookRequestDAO.MakePersistent(elo); BookRequestDAO.MakePersistent(el); EmailBO em = new EmailBO("EmptyLegAcceptedOfferNotificationToOperator", Session["Country"].ToString()); em.SendEmailToOperator(el.Aircraft.Vendor); Response.Redirect("EmptyLeg.aspx?eid=" + el.ID); } else { Error.InnerHtml = "* Sorry this empty leg offer have already been accepted."; } } else if (Request.Params.Get("savebidbtn") != null) { EmptyLeg el = BookRequestDAO.FindEmptyLegByID(Int64.Parse(Request.Params.Get("eid"))); if (el.OfferPrice <= Double.Parse(Request.Params.Get("bidamount"))) { Error.InnerHtml = "* Bid amount should be less than operator offered price."; } else if (el.AcceptedOffer != null) { Error.InnerHtml = "* Sorry this empty leg offer have already been accepted."; } else { EmptyLegOffer elo = new EmptyLegOffer(); elo.EmptyLeg = el; elo.Currency = el.Currency; elo.Status = 1; elo.TimeOfOffer = DateTime.Now; elo.IsAgent = false; elo.Customer = c; elo.BidAmount = Double.Parse(Request.Params.Get("bidamount")); elo.Agent = null; BookRequestDAO.MakePersistent(elo); EmailBO em = new EmailBO("EmptyLegOfferNotificationToOperator", Session["Country"].ToString()); em.SendEmailToOperator(el.Aircraft.Vendor); em = new EmailBO("EmptyLegOfferThanksToCustomer", Session["Country"].ToString()); if (!elo.IsAgent) { em.SendEmailToCustomer(elo.Customer); } ListSet othercust = new ListSet(); foreach (EmptyLegOffer eloc in BookRequestDAO.GetEmptyLegBids(el)) { if (eloc.IsAgent) { othercust.Add(eloc.Agent.Email.Trim()); } else { othercust.Add(eloc.Customer.Email.Trim()); } } if (elo.IsAgent) { othercust.Remove(elo.Agent.Email.Trim()); } else { othercust.Remove(elo.Customer.Email.Trim()); } ArrayList tempemail = new ArrayList(othercust); if (tempemail.Count > 0) { em = new EmailBO("EmptyLegOfferNotificationToOtherCustomers", Session["Country"].ToString()); em.SendEmailToList(tempemail); } Response.Redirect("EmptyLeg.aspx?eid=" + el.ID); } } }
public static EmptyLeg MakePersistent(EmptyLeg el) { NHibernateHelper.GetCurrentSession().SaveOrUpdate(el); return(el); }