Ejemplo n.º 1
0
        public Result AssignSalesperson(CustomerFormDTO dto)
        {
            // Check if there are any available personnel
            if (!_salesRepo.GetAllAvailableSalespersons(_salesRepo.LoadSalespersons()).Any())
            {
                // None available, return "All salespeople are busy. Please wait"
                return(new Result()
                {
                    Success = false,
                    ErrorMessage = "All salespeople are busy. Please wait."
                });
            }

            else if (dto.Groups.Count == 0)
            {
                // No groups so pick one at random
                var availablePerson = _salesRepo.LoadSalespersons();
                return(new Result()
                {
                    Success = true,
                    AssignedSalesPerson = ChooseRandom(availablePerson)
                });
            }

            else
            {
                // pass groups into function to find best salesperson
                return(AllocateSalesperson(dto.Groups));
            }
        }
Ejemplo n.º 2
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         CustomerFormDTO customer = new CustomerFormDTO();
         conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
         SqlConnection myConn = new SqlConnection(conn);
         myConn.Open();
         string        selectStatement = "Select * from Customers where (customerID="; selectStatement += dropDownCustID.SelectedValue + ")";
         SqlCommand    selectCmd       = new SqlCommand(selectStatement, myConn);
         SqlDataReader myReader;
         myReader = selectCmd.ExecuteReader();
         while (myReader.Read())
         {
             if (myReader.GetString(0) == dropDownCustID.SelectedValue)
             {
                 customer.id          = myReader.GetString(0);
                 customer.name        = myReader.GetString(1);
                 customer.surname     = myReader.GetString(2);
                 customer.address     = myReader.GetString(3);
                 customer.phoneNum    = myReader.GetString(4);
                 customer.altPhoneNum = myReader.GetString(5);
                 customer.items       = myReader.GetString(6);
                 break;
             }
         }
         myConn.Close();
         Session["CustomerDTO"] = customer;
         Server.Transfer("CustEdit2.aspx");
     }
     catch (SqlException ex)
     {
         Console.Write("Error : " + ex.ToString());
     }
 }
Ejemplo n.º 3
0
    protected void btnSubmitData_Click(object sender, EventArgs e)
    {
        CustomerFormDTO dto      = (CustomerFormDTO)Session["CustomerFormDTO"];
        ModelFacade     facade   = new ModelFacade();
        Customer        customer = facade.createCustomer(dto);
        CustomerDAO     doa      = new CustomerDAO();

        doa.saveCustomer(customer);
        Session.Abandon();
        Response.Redirect("~/Staff/AdminHome.aspx");
    }
Ejemplo n.º 4
0
        public Result ProcessAssignment(CustomerFormDTO formData)
        {
            Result dto = _assignor.AssignSalesperson(formData);

            if (dto.AssignedSalesPerson != null)
            {
                _writer.UpdateAvailability(dto.AssignedSalesPerson, false);
            }

            return(dto);
        }
Ejemplo n.º 5
0
    public Customer createCustomer(CustomerFormDTO dto)
    {
        Customer customerObject = new Customer();

        customerObject.customerID            = dto.id;
        customerObject.customerName          = dto.name;
        customerObject.customerSurname       = dto.surname;
        customerObject.customerAdress        = dto.address;
        customerObject.cutomerPhoneNumber    = dto.phoneNum;
        customerObject.customerAltPhoneNuber = dto.altPhoneNum;
        customerObject.totalItems            = dto.items;
        return(customerObject);
    }
Ejemplo n.º 6
0
    private void getSessionData()
    {
        CustomerFormDTO dto      = (CustomerFormDTO)Session["CustomerFormDTO"];
        ModelFacade     facade   = new ModelFacade();
        Customer        customer = facade.createCustomer(dto);

        lblID.Text             = customer.customerID.ToString();
        lblName.Text           = customer.customerName;
        lblSurname.Text        = customer.customerSurname;
        lblAddress.Text        = customer.customerAdress;
        lblPhoneNumber.Text    = customer.cutomerPhoneNumber;
        lblAltPhoneNumber.Text = customer.customerAltPhoneNuber;
        lblTotalItems.Text     = customer.totalItems.ToString();
    }
Ejemplo n.º 7
0
    protected void btnCustInsertNext_Click(object sender, EventArgs e)
    {
        String          custName           = txtCustName.Text;
        String          custSurname        = txtCustSurname.Text;
        String          custAddress        = txtCustAddress.Text;
        String          custPhoneNumber    = txtCustPhoneNumber.Text;
        String          custAltPhoneNumber = txtCustAltNumber.Text;
        String          totalItems         = txtTotalItems.Text;
        CustomerFormDTO customer           = new CustomerFormDTO();

        customer.id                = custID.ToString();
        customer.name              = custName;
        customer.surname           = custSurname;
        customer.address           = custAddress;
        customer.phoneNum          = custPhoneNumber;
        customer.altPhoneNum       = custAltPhoneNumber;
        customer.items             = totalItems;
        Session["CustomerFormDTO"] = customer;
        Server.Transfer("CustInsert2.aspx", true);
    }
Ejemplo n.º 8
0
 public Result Assign(CustomerFormDTO form)
 {
     return(_agent.ProcessAssignment(form));
 }