コード例 #1
0
        async private void accountSelected(object o)
        {
            if (o is Claim)
            {
                Claim = o as Claim;
                // Retrieve the Customer, Property Address, Billing Address, previous Inspection, and Lead information.
                Customer           = Customers.Where(c => c.CustomerID == Claim.CustomerID).Single();
                IsExistingCustomer = true;

                PropertyAddress   = Addresses.Where(a => a.AddressID == Claim.PropertyID).Single();
                IsExistingAddress = true;

                // Check if the BillingID is the same as PropertyID
                if (Claim.BillingID == Claim.PropertyID)
                {
                    /// BillingSameAsProperty = true;
                    BillingAddress = PropertyAddress;
                }
                else // If it's not retrieve the BillingAddress from the server
                {
                    ///BillingSameAsProperty = false;
                    BillingAddress = Addresses.Where(a => a.AddressID == Claim.BillingID).Single();
                }

                Lead = Leads.Where(l => l.LeadID == Claim.LeadID).Single();

                if (Lead.LeadTypeID == 1)
                {
                    if ((ErrorMessage = await new ServiceLayer().GetKnockerResponseByID(new DTO_KnockerResponse {
                        KnockerResponseID = (int)Lead.KnockerResponseID
                    })) != null)
                    {
                        return;
                    }
                    else
                    {
                        KnockerResponse = new KnockerResponse(ServiceLayer.KnockerResponse);
                    }
                }
                else if (Lead.LeadTypeID == 2)
                {
                    if ((ErrorMessage = await new ServiceLayer().GetReferrerByID(new DTO_Referrer {
                        ReferrerID = (int)Lead.CreditToID
                    })) != null)
                    {
                        return;
                    }
                    else
                    {
                        Referrer = new Referrer(ServiceLayer.Referrer);
                    }
                }

                Inspection = Inspections.Where(i => i.ClaimID == Claim.ClaimID).Single();

                Claim.InsuranceCompanyName = InsuranceCompanies.Where(i => i.InsuranceCompanyID == Claim.InsuranceCompanyID).Single().CompanyName;
            }
            else if (o is Lead)
            {
                Lead = o as Lead;
                // Retrieve the Customer and Property Address Information, and Claim if there is one attached.
                Customer           = Customers.Where(c => c.CustomerID == Lead.CustomerID).Single();
                IsExistingCustomer = true;
                PropertyAddress    = Addresses.Where(a => a.AddressID == Lead.AddressID).Single();
                IsExistingAddress  = true;
                BillingAddress     = null;

                // Check if any Claims are connected to the Lead
                if (Claims.Any(c => c.LeadID == Lead.LeadID))
                {
                    Claim = Claims.Where(c => c.LeadID == Lead.LeadID).Single();

                    // Check if BillingID is the same as PropertyID
                    if (Claim.BillingID == Claim.PropertyID)
                    {
                        ///BillingSameAsProperty = true;
                        BillingAddress     = PropertyAddress;
                        IsExistingAddressB = true;
                    }
                    else // If it's not retrieve the BillingAddress from the server
                    {
                        ///BillingSameAsProperty = false;
                        BillingAddress = Addresses.Where(a => a.AddressID == Claim.BillingID).Single();
                    }

                    // Retrieve the Inspection attached to the Claim
                    if ((ErrorMessage = await new ServiceLayer().GetInspectionsByClaimID(Claim.toDTO())) != null)
                    {
                        return;
                    }

                    Inspection = new Inspection(ServiceLayer.InspectionsList.Last());
                }
                else // Instantiate the Claim object
                {
                    Claim = new Claim {
                        LeadID = Lead.LeadID
                    };
                }

                BillingAddress = new Address();
                ///LeadIsAttached = true;
            }
            else if (o is Customer)
            {
                Customer = o as Customer;
            }
            else if (o is Address && code == 4)
            {
                PropertyAddress = o as Address;
            }
            else if (o is Address && code == 5)
            {
                BillingAddress = o as Address;
            }

            else if (o is Adjuster && code == 6)
            {
                Adjuster = o as Adjuster;
            }
            else if (o is Adjustment && code == 7)
            {
                Adjustment = o as Adjustment;
            }
            else if (o == null)
            {
                //AddLead.Execute(o);
            }

            CurrentPage = new ClaimHUDView();
            //OnRequestClose(this, new EventArgs());
        }
コード例 #2
0
        async private void setup()
        {
            Employees = new ObservableCollection <Employee>();

            ServiceLayer.EmployeesList = null;

            if ((ErrorMessage = await new ServiceLayer().GetEmployeesByEmployeeTypeID(new DTO_LU_EmployeeType {
                EmployeeTypeID = 14
            })) != null)
            {
                return;
            }

            foreach (DTO_Employee e in ServiceLayer.EmployeesList)
            {
                Employees.Add(new Employee(e));
            }

            if (Lead == null || Lead.LeadID <= 0)
            {
                Lead            = new Lead();
                Customer        = new Customer();
                PropertyAddress = new Address();
                KnockerResponse = new KnockerResponse();
                Referrer        = new Referrer();
            }
            else
            {
                if (Lead.SalespersonID <= 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().GetLeadByLeadID(Lead.toDTO())) != null)
                    {
                        return;
                    }
                }
                if ((ErrorMessage = await new ServiceLayer().GetCustomerByID(new DTO_Customer {
                    CustomerID = Lead.CustomerID
                })) != null)
                {
                    return;
                }
                Customer = new Customer(ServiceLayer.Customer);

                if ((ErrorMessage = await new ServiceLayer().GetAddressByID(new DTO_Address {
                    AddressID = Lead.AddressID
                })) != null)
                {
                    return;
                }
                PropertyAddress = new Address(ServiceLayer.Address);

                if (Lead.KnockerResponseID != null && Lead.KnockerResponseID > 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().GetKnockerResponseByID(new DTO_KnockerResponse {
                        KnockerResponseID = (int)Lead.KnockerResponseID
                    })) != null)
                    {
                        return;
                    }
                    KnockerResponse = new KnockerResponse(ServiceLayer.KnockerResponse);
                    Employee        = Employees.Where(e => e.EmployeeID == KnockerResponse.KnockerID).Single();
                }
            }
        }
コード例 #3
0
        async public void submitClaim(object o)
        {
            #region Process Lead

            // Create needed KnockerResponse or Referrer if needed.
            if (Lead.LeadTypeID == 1) // Knocker
            {
                // If KnockerResponse does not exist

                if (KnockerResponse.KnockerResponseID == 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().AddKnockerResponse(KnockerResponse.toDTO())) != null)
                    {
                        return;
                    }
                }
                else
                {
                    if ((ErrorMessage = await new ServiceLayer().UpdateKnockerResponse(KnockerResponse.toDTO())) != null)
                    {
                        return;
                    }
                }

                KnockerResponse        = new KnockerResponse(ServiceLayer.KnockerResponse);
                Lead.KnockerResponseID = KnockerResponse.KnockerResponseID;
                Lead.CreditToID        = KnockerResponse.KnockerID;
                //Lead.CreditTo = Employee.FirstName + " " + Employee.LastName;
            }
            else if (Lead.LeadTypeID == 2) // Referrer
            {
                if (Referrer.ReferrerID == 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().AddReferrer(Referrer.toDTO())) != null)
                    {
                        return;
                    }
                }
                else
                {
                    if ((ErrorMessage = await new ServiceLayer().UpdateReferrer(Referrer.toDTO())) != null)
                    {
                        return;
                    }
                }

                Referrer        = new Referrer(ServiceLayer.Referrer);
                Lead.CreditToID = Referrer.ReferrerID;
                Lead.CreditTo   = Referrer.FirstName + " " + Referrer.LastName;
            }

            Lead.SalespersonID = LoggedInEmployee.EmployeeID;
            Lead.CustomerID    = Customer.CustomerID;
            Lead.AddressID     = PropertyAddress.AddressID;
            Lead.Status        = "A";

            if (Lead.LeadID == 0)
            {
                if ((ErrorMessage = await new ServiceLayer().AddLead(Lead.toDTO())) != null)
                {
                    return;
                }

                Lead.LeadID = ServiceLayer.Lead.LeadID;
            }
            else
            {
                if ((ErrorMessage = await new ServiceLayer().UpdateLead(Lead.toDTO())) != null)
                {
                    return;
                }
            }

            #endregion

            #region Claim
            if (Claim.ClaimID == 0) // If the Claim doesn't exist (it should exist)
            {
                // Create the Claim
                if ((ErrorMessage = await new ServiceLayer().AddClaim(Claim.toDTO())) != null)
                {
                    return;
                }

                // Add it to the Claims list
                Claims.Add(new Claim(ServiceLayer.Claim));
            }
            else if (Claim.ClaimID > 0) // If the Claim does exist (it should)
            {
                // Update the Claim
                if ((ErrorMessage = await new ServiceLayer().UpdateClaim(Claim.toDTO())) != null)
                {
                    return;
                }

                // Overwrite the original Claim in the Claims list with the updated information
                Claim claim = Claims.Where(c => c.ClaimID == Claim.ClaimID).Single();
                int   index = Claims.IndexOf(claim);
                Claims[index] = new Claim(ServiceLayer.Claim);
                Customer      = Customers.Where(c => c.CustomerID == Claim.CustomerID).Single();
                Claims[index].CustomerName = Customer.FirstName + " " + Customer.LastName;
                Claims[index].Address      = Addresses.Where(a => a.AddressID == Claims[index].PropertyID).Single().FullAddress;
            }
            #endregion
        }
コード例 #4
0
        async private void submitLead(object o)
        {
            #region Process Customer
            if (!IsExistingCustomer)
            {
                if ((ErrorMessage = await new ServiceLayer().AddCustomer(Customer.toDTO())) != null)
                {
                    return;
                }

                Customer = new Customer(ServiceLayer.Customer);
                PropertyAddress.CustomerID = Customer.CustomerID;
            }

            else // If Customer does exist.
            {
                PropertyAddress.CustomerID = Customer.CustomerID;

                if ((ErrorMessage = await new ServiceLayer().UpdateCustomer(Customer.toDTO())) != null)
                {
                    return;
                }
            }
            #endregion

            #region Process Address
            if (PropertyAddress.AddressID == 0)
            {
                if ((ErrorMessage = await new ServiceLayer().AddAddress(PropertyAddress.toDTO())) != null)
                {
                    return;
                }

                PropertyAddress.AddressID = ServiceLayer.Address.AddressID;
            }
            else // If ProeprtyAddress does exist.
            {
                if ((ErrorMessage = await new ServiceLayer().UpdateAddress(PropertyAddress.toDTO())) != null)
                {
                    return;
                }
            }
            #endregion

            #region Process Lead
            if (Lead.LeadTypeID == 1)
            {
                // If KnockerResponse does not exist

                if (KnockerResponse.KnockerResponseID == 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().AddKnockerResponse(KnockerResponse.toDTO())) != null)
                    {
                        return;
                    }

                    KnockerResponse        = new KnockerResponse(ServiceLayer.KnockerResponse);
                    Lead.KnockerResponseID = KnockerResponse.KnockerResponseID;
                    Lead.CreditToID        = KnockerResponse.KnockerID;
                }
                else
                {
                    /// If KnockerRepsonse does exist?
                    /// Perhaps add checkbox to signal create window to select knocker response from table?
                    /// In which case this becomes a KnockerResponseUpdate area.
                }
            }
            else if (Lead.LeadTypeID == 2)
            {
                if (Referrer.ReferrerID == 0)
                {
                    if ((ErrorMessage = await new ServiceLayer().AddReferrer(Referrer.toDTO())) != null)
                    {
                        return;
                    }

                    Referrer        = new Referrer(ServiceLayer.Referrer);
                    Lead.CreditToID = Referrer.ReferrerID;
                }
                else
                {
                    /// If Referrer does exist?
                    /// Perhaps add checkbox to signal create window to select Referrer from table?
                    /// In which case this becomes a ReferrerUpdate area.
                }
            }

            Lead.SalespersonID = LoggedInEmployee.EmployeeID;
            Lead.CustomerID    = Customer.CustomerID;
            Lead.AddressID     = PropertyAddress.AddressID;
            Lead.Status        = "A";

            if (Lead.LeadID == 0)
            {
                if ((ErrorMessage = await new ServiceLayer().AddLead(Lead.toDTO())) != null)
                {
                    return;
                }

                Lead.LeadID = ServiceLayer.Lead.LeadID;
            }
            else
            {
                if ((ErrorMessage = await new ServiceLayer().UpdateLead(Lead.toDTO())) != null)
                {
                    return;
                }
            }

            OnRequestClose(this, new EventArgs());
            #endregion
        }