public void AddOrder(Order newOrder)
 {
     try
     {
         HostingUnit ExistsUnit = Converters.Conv_DO_To_BO(dal.GetHostingUnit(newOrder.HostingUnitKey));
         Host        ExistsHost = Converters.Conv_DO_To_BO(dal.GetHost(newOrder.HostId));
         if (ExistsUnit == null || ExistsHost == null)
         {
             throw new Exception("The unit or the host dosent exsist");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     try
     {
         GuestRequest request = GetRequest(newOrder.GuestRequestKey);
         HostingUnit  unit    = GetHoustingUinit(newOrder.HostingUnitKey);
         bool         valid   = CheckingAvailability(unit, request);
         if (!valid)
         {
             throw new Exception("The dates you requested are not available ");
         }
         dal.AddOrder(Converters.Conv_BO_To_DO(newOrder));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void AddPerson(Person item)
 {
     try
     {
         dal.AddPerson(Converters.Conv_BO_To_DO(item));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void UpdateOrder(Order updateor)
 {
     try
     {
         dal.UpdateOrder(Converters.Conv_BO_To_DO(updateor));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void UpdateRequest(GuestRequest toupdate)
 {
     try
     {
         dal.UpdateRequest(Converters.Conv_BO_To_DO(toupdate));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void UpdateHostingUnit(HostingUnit updateor)
 {
     try
     {
         dal.UpdateHostingUnit(Converters.Conv_BO_To_DO(updateor));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void UpdatePerson(Person toupdate)
 {
     try
     {
         dal.UpdatePerson(Converters.Conv_BO_To_DO(toupdate));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public void AddHost(Host toadd)
 {
     try
     {
         dal.AddHost(Converters.Conv_BO_To_DO(toadd));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public int AddHostingUinit(HostingUnit toAdd)
 {
     try
     {
         dal.AddHostingUnit(Converters.Conv_BO_To_DO(toAdd));
         return(toAdd.Key);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        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;
            }
        }
 public int AddRequest(GuestRequest item)
 {
     if ((item.LeaveDate - item.EntryDate).Days < 1)
     {
         throw new Exception("The exit must be dropped one day after entering");
     }
     try
     {
         dal.AddGuestRequest(Converters.Conv_BO_To_DO(item));
     }
     catch (Exception e)
     {
         throw e;
     }
     return(item.Key);
 }
Example #11
0
 public int AddRequest(GuestRequest item)
 {
     if ((item.LeaveDate - item.EntryDate).Days < 1)
     {
         throw new Exception("The exit must be dropped one day after entering");
     }
     if (DateTime.Today.AddMonths(11) <= item.LeaveDate)
     {
         throw new Exception("אין אפשרות לקבוע מעבר ל 11 חודשים קדימה ");
     }
     try
     {
         int key = dal.AddGuestRequest(Converters.Conv_BO_To_DO(item));
         return(key);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #12
0
 public bool SetDairy(HostingUnit unit, GuestRequest request)
 {
     if (!CheckingAvailability(unit, request))
     {
         return(false);
     }
     for (DateTime entery = request.EntryDate; entery != request.LeaveDate; entery = entery.AddDays(1))
     {
         unit.Diary[entery.Month - 1, entery.Day] = true;
     }
     try
     {
         dal.UpdateHostingUnit(Converters.Conv_BO_To_DO(unit));
     }
     catch (Exception e)
     {
         throw e;
     }
     return(true);
 }