Exemplo n.º 1
0
 public void AddGuestRequest(GuestRequest myGuestRequest)
 {
     if (myGuestRequest.ReleaseDate <= myGuestRequest.EntryDate)
     {
         throw new ArgumentException("Second date must be later than first date.");
     }
     if (myGuestRequest.EntryDate <= DateTime.Now)
     {
         throw new ArgumentException("Entry date must be later than today.");
     }
     if (myGuestRequest.ReleaseDate > DateTime.Now.AddMonths(11))
     {
         throw new ArgumentException("you can look for hosting unit up to 11 months in advance.");
     }
     myGuestRequest.RegistrationDate = DateTime.Now;
     try
     {
         dal.AddGuestRequest(myGuestRequest);
         List <HostingUnit> matchHostingUnitsToRequest = ReceiveMatchHostingUnitForRequest(myGuestRequest);
         foreach (var item in matchHostingUnitsToRequest)
         {
             CreateOrderAndSendMailForHostingUnit(item, myGuestRequest);
         }
         if (matchHostingUnitsToRequest.FindIndex(x => x.Owner.CollectionClearance) == -1)
         {
             throw new ArgumentException("מצטערים, לא מצאנו יחידות אירוח מתאימות לבקשתך. " +
                                         "בקשתך נשמרה במערכת, אם נמצא יחידות אירוח מתאימות עבורך מאוחר יותר, נעדכן אותך באימייל");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        public string AddGuestRequest(BE.GuestRequest guestR) // add guest request
        {
            guestR.GuestRequestKey = 0;
            if (!CheckMailAddress(guestR.MailAddress))
            {
                throw new ArgumentException("This email address isn't correct");
            }
            guestR.Status           = BE.GUESTSTATUS.Active;
            guestR.RegistrationDate = DateTime.Now;
            if (!CheckDates(guestR.EntryDate, guestR.ReleaseDate))
            {
                throw new ArgumentException("ERROR DATES-Entry date must be before Release Date");
            }
            if (guestR.Vacationers == 0)
            {
                throw new ArgumentException("ERROR-You have to add vacationners");
            }
            if (guestR.ReleaseDate >= DateTime.Now.AddYears(1))
            {
                throw new ArgumentException("You cannot register for duration more than year");
            }
            if (Convert.ToInt32(guestR.Area) < 0 || Convert.ToInt32(guestR.Area) > 4)
            {
                throw new ArgumentException("ERROR-This number of Area dosn't exist");
            }
            if (Convert.ToInt32(guestR.Type) < 0 || Convert.ToInt32(guestR.Type) > 3)
            {
                throw new ArgumentException("ERROR-This number of Type dosn't exist");
            }
            if (guestR.Adults < 0 || guestR.Children < 0)
            {
                throw new ArgumentException("ERROR-The number of adults and childrens have to be positive");
            }
            if (Convert.ToInt32(guestR.Pool) < 0 || Convert.ToInt32(guestR.Pool) > 2)
            {
                throw new ArgumentException("ERROR-This number of Choice for the pool dosn't exist");
            }
            if (Convert.ToInt32(guestR.Garden) < 0 || Convert.ToInt32(guestR.Garden) > 2)
            {
                throw new ArgumentException("ERROR-This number of Choice for the garden dosn't exist");
            }
            if (Convert.ToInt32(guestR.Jacuzzi) < 0 || Convert.ToInt32(guestR.Jacuzzi) > 2)
            {
                throw new ArgumentException("ERROR-This number of Choice for the jacuzzi dosn't exist");
            }

            dal.AddGuestRequest(guestR);
            return("Add Guest Request accomplish with success , you will soon receive an email from Hosts\nYour Guest Request key is:\n" + guestR.GuestRequestKey);
        }