Ejemplo n.º 1
0
 public static Agent GetLoggedInAgent()
 {
     try
     {
         if (HttpContext.Current.User.IsInRole("Agent"))
         {
             Agent a = AgentDAO.FindAgentByID(Int64.Parse(HttpContext.Current.User.Identity.Name));
             return(a);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Agent a = AgentDAO.FindAgentByID(Int64.Parse(Request.Params.Get("aid")));

        if (Request.Params.Get("generatepassword") != null)
        {
            a.Password = AgentBO.GeneratePassword();
            AgentDAO.MakePersistent(a);
            Session["done"] = "1";
        }
        if (Request.Params.Get("generatecode") != null)
        {
            a.CalculateAgentCode();
            AgentDAO.MakePersistent(a);
            Session["done"] = "1";
        }
        if (Request.Params.Get("emaillink") != null)
        {
            Session["done"] = "1";
            EmailBO em = new EmailBO("AgentPersonalDetails", a.Domain);
            em.SendEmailToAgent(a);
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Int32       nooflegs   = Int32.Parse(Request.Params.Get("nooflegs"));
            BookRequest b          = new BookRequest();
            Customer    check      = CustomerBO.GetLoggedInCustomer();
            Agent       agentcheck = AgentBO.GetLoggedInAgent();

            b.IsAgent = false;
            Contact c = new Contact();
            if (check != null)
            {
                c.Name  = check.Name;
                c.Email = check.Email;
                c.Phone = check.ContactNo;
            }
            else
            {
                c.Name  = Request.Params.Get("Name");
                c.Email = Request.Params.Get("Email");
                c.Phone = Request.Params.Get("ContactNo");


                if (agentcheck != null)
                {
                    b.IsAgent = true;
                    b.Agent   = agentcheck;
                }
                else if (Session["AgentID"] != null)
                {
                    b.IsAgent = true;
                    Agent a = AgentDAO.FindAgentByID((long)Session["AgentID"]);
                    b.Agent = a;
                }
                else
                {
                    Customer custemail = CustomerDAO.CheckCustomerByEmail(Request.Params.Get("Email"));
                    if (custemail == null)
                    {
                        Customer cust = new Customer();
                        cust.Email     = Request.Params.Get("Email");;
                        cust.ContactNo = Request.Params.Get("ContactNo");
                        cust.Name      = Request.Params.Get("Name");
                        cust.Password  = CustomerBO.GeneratePassword();
                        cust.Status    = 1;
                        CustomerDAO.MakePersistent(cust);
                        check = cust;
                        EmailBO em = new EmailBO("NewCustomer", Session["Country"].ToString());
                        em.SendEmailToCustomer(check);
                    }
                    else
                    {
                        check = custemail;
                    }
                }
            }
            if (Request.Params.Get("fixedpricecharter") != null)
            {
                FixedPriceCharter el = BookRequestDAO.FindFixedPriceCharterByID(Int64.Parse(Request.Params.Get("fixedpricecharter")));
                b.FixedPriceCharter = el;
            }
            c.Description    = Request.Params.Get("OtherDetails");
            b.PAX            = Int32.Parse(Request.Params.Get("PAX"));
            b.Budget         = Double.Parse(Request.Params.Get("budget"));
            b.FinalBudget    = BookRequestBO.GetFinalBudget(b.Budget, AdminBO.GetCountry());
            b.ContactDetails = c;
            b.TimeofCreation = DateTime.Now;
            b.TripType       = Request.Params.Get("TripType");
            AirplaneType apt = OperatorDAO.FindAircraftTypeByID(Request.Params.Get("aircrafttype"));
            b.PlaneType = apt;
            b.Status    = 0;
            b.Domain    = AdminDAO.GetCountryByID(Session["Country"].ToString());
            for (int i = 1; i <= nooflegs; i++)
            {
                Leg l = new Leg();
                l.Sequence = i;
                ListSet fromairfields = AirfieldBO.GetAirfields(Request.Params.Get("fromleg" + i));
                ListSet toairfields   = AirfieldBO.GetAirfields(Request.Params.Get("toleg" + i));

                foreach (Airfield a in fromairfields)
                {
                    if (l.Source == null)
                    {
                        l.Source = a;
                    }
                }
                if (l.Source.IsTemporary())
                {
                    l.Source = AirfieldBO.SaveAirfield(l.Source);
                }
                foreach (Airfield a in toairfields)
                {
                    if (l.Destination == null)
                    {
                        l.Destination = a;
                    }
                }
                if (l.Destination.IsTemporary())
                {
                    l.Destination = AirfieldBO.SaveAirfield(l.Destination);
                }
                l.Date = DateTime.Parse(Request.Params.Get("dateleg" + i) + " " + Request.Params.Get("timeleg" + i));
                b.AddLeg(l);
            }

            b = BookRequestBO.AcceptBookRequest(b);
            if (b.FixedPriceCharter == null)
            {
                OperatorResolver opr = new OperatorResolver(OperatorBO.OperatorResolve);
                opr.BeginInvoke(b, null, null);
            }
            else
            {
                EmailBO em = new EmailBO("FixedPriceCharterNotificationToOperator", Session["Country"].ToString());
                em.SendEmailToOperator(b.FixedPriceCharter.Aircraft.Vendor);
            }
            if (b.IsAgent)
            {
                EmailBO em = new EmailBO("AgentThanksRequest", Session["Country"].ToString());
                em.SendEmailToAgent(b.Agent);
            }
            else
            {
                EmailBO em = new EmailBO("CustomerThanksRequest", Session["Country"].ToString());
                em.SendEmailToCustomer(check);
            }
            Session.Add("bid", b.BookID);
        }
        catch (AifieldNotFoundException ax)
        {
            Response.Redirect(Request.UrlReferrer.OriginalString + "?" + Serialize(Request.QueryString));
        }
        catch (Exception ex)
        {
            Response.Redirect("QuickQuote.aspx");
        }
        Response.Redirect("RequestSent.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CharterTemplate mp = (CharterTemplate)Page.Master;

        mp.selectedtab = "agent";
        Status.Visible = false;
        foreach (Country c in OperatorDAO.GetCountries())
        {
            country.Items.Add(new ListItem(c.FullName, c.CountryID));
        }
        if (Session["agentregistrationdone"] == "1")
        {
            Status.Visible   = true;
            Status.InnerHtml = "Thank You.The registration details have been sent to the Airnetz Administration.You will receive an email shortly depending upon approval.";
            Status.Attributes.Add("class", "boldtext");
            Session["agentregistrationdone"] = null;
        }
        if (IsPostBack)
        {
            try
            {
                Session["operatorregistrationdone"] = null;
                if (AgentDAO.GetAgentByEmail(Email.Value) != null)
                {
                    throw new NHibernate.HibernateException();
                }
                Agent a = new Agent();
                a.Name           = AgentName.Value;
                a.Domain         = Session["Country"].ToString();
                a.Email          = Email.Value;
                a.Email1         = AlternateEmail.Value;
                a.ContactNo      = ContactNo.Value;
                a.ContactNo1     = AlternateContactNo.Value;
                a.Country        = country.Value;
                a.BillingAddress = BillingAddress.Value;
                a.Agency         = AgencyName.Value;
                a.AgentFax       = Fax.Value;
                a.Password       = Password.Value;
                a.CalculateAgentCode();
                a.Status = 0;
                AgentDAO.MakePersistent(a);
                Session["agentregistrationdone"] = "1";
                EmailBO em = new EmailBO("AgentRegistrationThanks", Session["Country"].ToString());
                em.SendEmailToAgent(a);
                Response.Redirect("AgentRegister.aspx", false);
            }
            catch (NHibernate.HibernateException hx)
            {
                Status.Visible = true;
                Status.Style.Add("color", "red");
                Status.InnerHtml = "Email already taken.";
                Status.Attributes.Add("class", "error");
            }
            catch (Exception ex)
            {
                Status.Visible = true;
                Status.Attributes.Add("class", "error");
                Status.InnerHtml = "Some unexpected problem occured.Please try again.";
            }
        }
    }
Ejemplo n.º 5
0
        public static Agent CheckAgentCode(String AgentCode)
        {
            Agent a = AgentDAO.FindAgentByCode(AgentCode);

            return(a);
        }