Ejemplo n.º 1
0
 public int AddGuestRequest(BO.GuestRequest guestRequest)//
 {
     if (CheckDate(guestRequest))
     {
         return(dal.AddGuesetRequest(Conversions.CastingToDOGuestRequest(guestRequest)));
     }
     return(0);
 }
        private void ShowRequestButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            BO.GuestRequest guestRequest = (BO.GuestRequest)button.DataContext;
            ShowRequest     window       = new ShowRequest(bl, guestRequest);

            window.Show();
        }
Ejemplo n.º 3
0
        public IEnumerable <BO.HostingUnit> CheckForAvailableHostingUnit(DateTime date, int days)
        {
            DateTime end = date.AddDays(days);

            BO.GuestRequest temp = new BO.GuestRequest()
            {
                EntryDate = date, ReleaseDate = end
            };
            return(GetHostingUnits().Where(x => IsAvailableGuestRequest(temp, x)));
        }
        private void UpdateRequestButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            BO.GuestRequest guestRequest = (BO.GuestRequest)button.DataContext;
            UpdateRequest   window       = new UpdateRequest(bl, guestRequest);

            window.Show();
            this.RequestsViewList.ItemsSource = lstRequest;
            this.RequestsViewList.Items.Refresh();
        }
        public void UpdateStatusOrder(BO.OrderStatus updateorder, int key)
        {
            try
            {
                BO.Order tmp1 = Converters.Conv_DO_To_BO(dal.GetOrder(key));
                if (tmp1.Status == OrderStatus.IGNORED_CLOSED || tmp1.Status == OrderStatus.APPROVED)
                {
                    throw new Exception("אין אפשרות לשנות את הסטטוס לאחר סגירת עסקה");
                }
                BO.Host temp2 = Converters.Conv_DO_To_BO(dal.GetHost(tmp1.HostId));
                if (updateorder == OrderStatus.MAIL_SENT)
                {
                    if (!temp2.CollectionClearance)
                    {
                        throw new Exception("אין אפשרות לשלוח מייל ללקוח מבלי לחתום על הרשאה לחיוב חשבון");
                    }
                }
                if (updateorder == OrderStatus.APPROVED)
                {
                    BO.Order        update  = Converters.Conv_DO_To_BO(dal.GetOrder(key));
                    BO.HostingUnit  unit    = Converters.Conv_DO_To_BO(dal.GetHostingUnit(update.HostingUnitKey));
                    BO.GuestRequest request = Converters.Conv_DO_To_BO(dal.GetGuestRequest(update.GuestRequestKey));
                    SetDairy(unit, request);
                    dal.UpdateHostingUnit(Converters.Conv_BO_To_DO(unit));
                    update.ClientName = dal.GetPerson(update.ClientId).FirstName + dal.GetPerson(update.ClientId).LastName;
                    update.Commission = 10; //סכום העמלה
                    dal.UpdateOrder(Converters.Conv_BO_To_DO(update));
                    List <Order> lst = GetOrdersByRequestKey(request.Key).ToList();
                    foreach (var i in lst)//change all orders to Irrelevant
                    {
                        if (i.Key != update.Key)
                        {
                            dal.UpdateStatusOrder(i.Key, DO.OrderStatus.IRRELEVANT);
                        }
                    }
                    try
                    {
                        SendEmail(tmp1);
                    }
                    catch (Exception)
                    {
                        throw new Exception("Check your Internet connection");
                    }

                    ////////////////////////////////////////////////////////////////////////////////////////
                }
                dal.UpdateStatusOrder(key, (DO.OrderStatus)updateorder);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 6
0
 public void UpdateGusetRequest(BO.GuestRequest request)
 {
     if (NumberOfInvitationsSent(request) == 0)
     {
         if (CheckDate(request))
         {
             dal.UpdateGusetRequest(Conversions.CastingToDOGuestRequest(request));
         }
     }
     else
     {
         throw new InvalidOperationException("You can't change a guest request that has open invitations for it");
     }
 }
Ejemplo n.º 7
0
        public bool IsAvailableGuestRequest(BO.GuestRequest guestRequest, BO.HostingUnit hostingUnit)//
        {
            DateTime temp = guestRequest.EntryDate;

            while (temp != guestRequest.ReleaseDate)
            {
                if (hostingUnit.GetDate(temp) == true)
                {
                    return(false);
                }
                temp = temp.AddDays(1);
            }
            return(true);
        }
Ejemplo n.º 8
0
 public bool CheckDate(BO.GuestRequest guestRequest)
 {
     if (guestRequest.ReleaseDate <= guestRequest.EntryDate)
     {
         throw new ArgumentOutOfRangeException("The release date must be at least one day after the entry date");
     }
     else
     {
         DateTime temp = DateTime.Now;
         if (guestRequest.ReleaseDate >= temp.AddMonths(11))
         {
             throw new ArgumentOutOfRangeException("Sorry, you can't place an order that ends elven months or more from today");
         }
     }
     return(true);
 }
        private void DeleteRequestButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            BO.GuestRequest guestRequest = (BO.GuestRequest)button.DataContext;
            try
            {
                bl.UpdateRequestStatus(RequestStatus.IRRELEVANT, guestRequest.Key);//update the staus as Irlevent
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            lstRequest = bl.GetGuestRequestByPredicate(x => x.ClientId == int.Parse(tb_GuestId.Text) && x.Status != RequestStatus.IRRELEVANT);
            this.RequestsViewList.ItemsSource = lstRequest;
            this.RequestsViewList.Items.Refresh();
        }
 public static DO.GuestRequest Conv_BO_To_DO(BO.GuestRequest item)
 {
     DO.GuestRequest temp = new DO.GuestRequest();
     temp.Adults               = item.Adults;
     temp.Area                 = (DO.Areas)item.Area;
     temp.Children             = item.Children;
     temp.ChildrensAttractions = (DO.Answer)item.ChildrensAttractions;
     temp.ClientId             = item.ClientId;
     temp.CreateDate           = item.CreateDate;
     temp.EntryDate            = item.EntryDate;
     temp.Garden               = (DO.Answer)item.Garden;
     temp.Jacuzzi              = (DO.Answer)item.Jacuzzi;
     temp.Key       = item.Key;
     temp.LeaveDate = item.LeaveDate;
     temp.Pool      = (DO.Answer)item.Pool;
     temp.Rooms     = item.Rooms;
     temp.Status    = (DO.RequestStatus)item.Status;
     temp.SubArea   = item.SubArea;
     temp.Type      = (DO.HostingType)item.Type;
     return(temp);
 }
Ejemplo n.º 11
0
 public static DO.GuestRequest CastingToDOGuestRequest(BO.GuestRequest guestRequest)
 {
     DO.GuestRequest GR = new DO.GuestRequest()
     {
         Adults = guestRequest.Adults,
         Area   = (DO.Location)guestRequest.Area,
         ChildrensAttractions = (DO.Preferences)guestRequest.ChildrensAttractions,
         SubArea          = guestRequest.SubArea,
         Status           = (DO.Request_Statut)guestRequest.Status,
         children         = guestRequest.children,
         ClientID         = guestRequest.ClientID,
         EntryDate        = guestRequest.EntryDate,
         ReleaseDate      = guestRequest.ReleaseDate,
         RegistrationDate = guestRequest.RegistrationDate,
         Garden           = (DO.Preferences)guestRequest.Garden,
         GuestRequestKey  = guestRequest.GuestRequestKey,
         Jacuzzi          = (DO.Preferences)guestRequest.Jacuzzi,
         Pool             = (DO.Preferences)guestRequest.Pool,
         Type             = (DO.Hosting_Type)guestRequest.HostingType
     };
     return(GR);
 }
Ejemplo n.º 12
0
        }///

        public int NumberOfInvitationsSent(BO.GuestRequest guestRequest)//
        {
            return((dal.GetOrdersList(x => x.GuestRequestKey == guestRequest.GuestRequestKey)).Count());
        }