Ejemplo n.º 1
0
        public void AddReservationsHavingUnpayedThrowsException()
        {
            Reservation r1 = new Reservation()
            {
                ReservationDate = DateTime.Now.AddMonths(-1)
            };
            Reservation r2 = new Reservation()
            {
                ReservationDate = DateTime.Now
            };

            using (IUnitOfWork unitOfWork = GetContext())
            {
                using (ReservationManagement reservationManagement = new ReservationManagement(unitOfWork, TestHelper.GetGenericPrincipalAdmin(), Mapper.Instance))
                {
                    reservationManagement.Add(r1);
                    Assert.Throws <BussinesException>(() => reservationManagement.Add(r2));
                }
            }
        }
Ejemplo n.º 2
0
        public void MakeReservation()
        {
            Reservations _newreservation = new Reservations();

            Customers _newcustomer = new Customers();

            ReservationCustomerRoom _reservationcustomerroom = new ReservationCustomerRoom();

            _newreservation.CreatedBy         = Convert.ToInt32(Session["userID"]);
            _newreservation.CreatedDate       = DateTime.Now.Date;
            _newreservation.ReservationTypeID = Convert.ToInt32(ddlreservationtype.SelectedValue);
            _newreservation.ReservationPrice  = CalculateReservationPrice(Int32.Parse(ddltotalperson.SelectedValue), chkindate.Text, chkoutdate.Text);
            _newreservation.TotalPeople       = Convert.ToInt16(ddltotalperson.Text);
            _newreservation.DateOfEntry       = Convert.ToDateTime(chkindate.Text);
            _newreservation.DateOfOut         = Convert.ToDateTime(chkoutdate.Text);
            _newreservation.LastModifiedDate  = DateTime.Now.Date;
            _newreservation.IsActive          = true;


            _newcustomer.CustomerName         = txtfirstname.Value;
            _newcustomer.CustomerLastName     = txtlastname.Value;
            _newcustomer.CustomerCivilization = txtcivilnumber.Value;
            _newcustomer.Gender           = ddlgender.Text;
            _newcustomer.CreationDate     = DateTime.Now.Date;
            _newcustomer.LastModifiedDate = DateTime.Now.Date;


            _reservationmanagement.Add(_newreservation);

            Session["ReservationID"] = "P08000" + _newreservation.ReservationID;

            _customermanagement.Add(_newcustomer);

            _reservationcustomerroom.ReservationID = _newreservation.ReservationID;
            _reservationcustomerroom.RoomID        = Int32.Parse(ddlGuestNumber.SelectedValue);
            _reservationcustomerroom.CustomerID    = _newcustomer.CustomerID;
            _reservationroomcustomermanagement.Add(_reservationcustomerroom);

            int index        = 1;
            int roomindex    = 0;
            int roomcounter  = 0;
            int roomcounter2 = 0;


            Customers customer;
            ReservationCustomerRoom _reservationcustomerroomOtherC;

            int totalPeople = Convert.ToInt32(ddltotalperson.Text);


            string txtcustomername;

            string txtcustomerlastname;

            string txtcustomercivilization;

            string txtgender;

            string txtroomnumber;

            string txtroomnumber2;

            string txtroomnumber3;


            if (totalPeople < 4)
            {
                for (int i = 1; i <= totalPeople; i++)
                {
                    txtcustomername = string.Format("ctl00$ContentPlaceHolder1$Guest{0}First Name", index);

                    txtcustomerlastname     = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Last Name", index);
                    txtcustomercivilization = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Civilization Number", index);
                    txtgender = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Gender", index);


                    if (Request.Form.AllKeys.Contains(txtcustomername) && Request.Form.AllKeys.Contains(txtcustomerlastname) &&
                        Request.Form.AllKeys.Contains(txtcustomercivilization) && Request.Form.AllKeys.Contains(txtgender))
                    {
                        txtcustomername         = Request.Form[txtcustomername];
                        txtcustomerlastname     = Request.Form[txtcustomerlastname];
                        txtcustomercivilization = Request.Form[txtcustomercivilization];
                        txtgender = Request.Form[txtgender];


                        customer = new Customers();
                        customer.CustomerName         = txtcustomername;
                        customer.CustomerLastName     = txtcustomerlastname;
                        customer.CustomerCivilization = txtcustomercivilization;
                        customer.Gender           = txtgender;
                        customer.CreationDate     = DateTime.Now.Date;
                        customer.LastModifiedDate = DateTime.Now.Date;

                        _customermanagement.Add(customer);


                        _reservationcustomerroomOtherC = new ReservationCustomerRoom();

                        _reservationcustomerroomOtherC.CustomerID    = customer.CustomerID;
                        _reservationcustomerroomOtherC.ReservationID = _newreservation.ReservationID;
                        _reservationcustomerroomOtherC.RoomID        = Int32.Parse(ddlGuestNumber.SelectedValue);
                        _reservationroomcustomermanagement.Add(_reservationcustomerroomOtherC);
                    }
                    index++;
                }
            }


            else if (totalPeople >= 4 && totalPeople < 7)
            {
                for (int i = 1; i < totalPeople; i++)
                {
                    //if(i == (totalPeople - 2))
                    //{
                    //    break;
                    //}


                    roomindex               = 2;
                    txtcustomername         = string.Format("ctl00$ContentPlaceHolder1$Guest{0}First Name", index);
                    txtcustomerlastname     = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Last Name", index);
                    txtcustomercivilization = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Civilization Number", index);
                    txtgender               = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Gender", index);

                    txtroomnumber = string.Format("ctl00$ContentPlaceHolder1$Guest{0}", roomindex);

                    if (Request.Form.AllKeys.Contains(txtcustomername) && Request.Form.AllKeys.Contains(txtcustomerlastname) &&
                        Request.Form.AllKeys.Contains(txtcustomercivilization) && Request.Form.AllKeys.Contains(txtgender) && Request.Form.AllKeys.Contains(txtroomnumber))
                    {
                        txtcustomername         = Request.Form[txtcustomername];
                        txtcustomerlastname     = Request.Form[txtcustomerlastname];
                        txtcustomercivilization = Request.Form[txtcustomercivilization];
                        txtgender     = Request.Form[txtgender];
                        txtroomnumber = Request.Form[txtroomnumber];

                        customer = new Customers();
                        customer.CustomerName         = txtcustomername;
                        customer.CustomerLastName     = txtcustomerlastname;
                        customer.CustomerCivilization = txtcustomercivilization;
                        customer.Gender           = txtgender;
                        customer.CreationDate     = DateTime.Now.Date;
                        customer.LastModifiedDate = DateTime.Now.Date;



                        _customermanagement.Add(customer);


                        _reservationcustomerroomOtherC = new ReservationCustomerRoom();

                        _reservationcustomerroomOtherC.CustomerID    = customer.CustomerID;
                        _reservationcustomerroomOtherC.ReservationID = _newreservation.ReservationID; _reservationcustomerroomOtherC.RoomID = Int32.Parse(ddlGuestNumber.SelectedValue);
                        if (i >= 3 && i <= 6)
                        {
                            _reservationcustomerroomOtherC.RoomID = Int32.Parse(txtroomnumber);
                        }
                        _reservationroomcustomermanagement.Add(_reservationcustomerroomOtherC);
                    }



                    index++;
                }
            }

            else if (totalPeople >= 7 && totalPeople < 10)
            {
                roomindex   = 2;
                roomcounter = 5;



                for (int i = 1; i < totalPeople; i++)
                {
                    txtcustomername         = string.Format("ctl00$ContentPlaceHolder1$Guest{0}First Name", index);
                    txtcustomerlastname     = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Last Name", index);
                    txtcustomercivilization = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Civilization Number", index);
                    txtgender = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Gender", index);

                    txtroomnumber = string.Format("ctl00$ContentPlaceHolder1$Guest{0}", roomindex);

                    txtroomnumber2 = string.Format("ctl00$ContentPlaceHolder1$Guest{0}", roomcounter);



                    if (Request.Form.AllKeys.Contains(txtcustomername) && Request.Form.AllKeys.Contains(txtcustomerlastname) &&
                        Request.Form.AllKeys.Contains(txtcustomercivilization) && Request.Form.AllKeys.Contains(txtgender) && Request.Form.AllKeys.Contains(txtroomnumber) && Request.Form.AllKeys.Contains(txtroomnumber2))
                    {
                        txtcustomername         = Request.Form[txtcustomername];
                        txtcustomerlastname     = Request.Form[txtcustomerlastname];
                        txtcustomercivilization = Request.Form[txtcustomercivilization];
                        txtgender      = Request.Form[txtgender];
                        txtroomnumber  = Request.Form[txtroomnumber];
                        txtroomnumber2 = Request.Form[txtroomnumber2];

                        customer = new Customers();
                        customer.CustomerName         = txtcustomername;
                        customer.CustomerLastName     = txtcustomerlastname;
                        customer.CustomerCivilization = txtcustomercivilization;
                        customer.Gender           = txtgender;
                        customer.CreationDate     = DateTime.Now.Date;
                        customer.LastModifiedDate = DateTime.Now.Date;



                        _customermanagement.Add(customer);


                        _reservationcustomerroomOtherC = new ReservationCustomerRoom();

                        _reservationcustomerroomOtherC.CustomerID    = customer.CustomerID;
                        _reservationcustomerroomOtherC.ReservationID = _newreservation.ReservationID;
                        _reservationcustomerroomOtherC.RoomID        = Int32.Parse(ddlGuestNumber.SelectedValue);

                        if (i >= 3 && i <= 6)
                        {
                            _reservationcustomerroomOtherC.RoomID = Int32.Parse(txtroomnumber);
                        }

                        if (i >= 7 && i <= 9)
                        {
                            _reservationcustomerroomOtherC.RoomID = Int32.Parse(txtroomnumber);
                        }
                        _reservationroomcustomermanagement.Add(_reservationcustomerroomOtherC);
                    }

                    index++;

                    if (i == 5)
                    {
                        roomindex += 3;
                    }
                }
            }

            else if (totalPeople == 10)
            {
                roomindex    = 2;
                roomcounter  = 5;
                roomcounter2 = 8;
                for (int i = 1; i < totalPeople; i++)
                {
                    txtcustomername         = string.Format("ctl00$ContentPlaceHolder1$Guest{0}First Name", index);
                    txtcustomerlastname     = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Last Name", index);
                    txtcustomercivilization = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Civilization Number", index);
                    txtgender = string.Format("ctl00$ContentPlaceHolder1$Guest{0}Gender", index);

                    txtroomnumber = string.Format("ctl00$ContentPlaceHolder1$Guest{0}", roomindex);



                    txtroomnumber3 = string.Format("ctl00$ContentPlaceHolder1$Guest{0}", roomcounter2);

                    if (Request.Form.AllKeys.Contains(txtcustomername) && Request.Form.AllKeys.Contains(txtcustomerlastname) &&
                        Request.Form.AllKeys.Contains(txtcustomercivilization) && Request.Form.AllKeys.Contains(txtgender) && Request.Form.AllKeys.Contains(txtroomnumber))
                    {
                        txtcustomername         = Request.Form[txtcustomername];
                        txtcustomerlastname     = Request.Form[txtcustomerlastname];
                        txtcustomercivilization = Request.Form[txtcustomercivilization];
                        txtgender     = Request.Form[txtgender];
                        txtroomnumber = Request.Form[txtroomnumber];

                        customer = new Customers();
                        customer.CustomerName         = txtcustomername;
                        customer.CustomerLastName     = txtcustomerlastname;
                        customer.CustomerCivilization = txtcustomercivilization;
                        customer.Gender           = txtgender;
                        customer.CreationDate     = DateTime.Now.Date;
                        customer.LastModifiedDate = DateTime.Now.Date;

                        _customermanagement.Add(customer);


                        _reservationcustomerroomOtherC = new ReservationCustomerRoom();

                        _reservationcustomerroomOtherC.CustomerID    = customer.CustomerID;
                        _reservationcustomerroomOtherC.ReservationID = _newreservation.ReservationID;
                        _reservationcustomerroomOtherC.RoomID        = Int32.Parse(ddlGuestNumber.SelectedValue);
                        if (i >= 3 && i <= 6)
                        {
                            _reservationcustomerroomOtherC.RoomID = Int32.Parse(txtroomnumber);
                        }

                        if (i >= 7 && i <= 9)
                        {
                            _reservationcustomerroomOtherC.RoomID = Int32.Parse(txtroomnumber);
                        }
                        if (i == 10)
                        {
                            _reservationcustomerroomOtherC.RoomID = Int32.Parse(txtroomnumber);
                        }

                        _reservationroomcustomermanagement.Add(_reservationcustomerroomOtherC);
                    }

                    index++;

                    if (i == 5)
                    {
                        roomindex += 3;
                    }

                    else if (i == 8)
                    {
                        roomindex += 3;
                    }
                }
            }

            Response.Redirect("PaymentPage.aspx", false);
        }