/// <summary>
        /// add order to date base
        /// </summary>
        /// <param name="order"></param>
        public void addOrder(BE.Order order)
        {
            BE.GuestRequest tmp = null;

            tmp = rGuest(order);

            BE.HostingUnit tmp2 = rHosting(order);
            int            days = (tmp.ReleaseDate - tmp.EntryDate).Days;

            int price = (BE.Configuration.Commission * days);

            if (ApproveRequest(tmp, tmp2))
            {
                //סימון במטריצה
                Approve(tmp, tmp2);
                if (tmp2.Owner.CollectionClearance)
                {
                    order.Status = BE.StatusGuest.נשלח_מייל;

                    order.OrderDate = DateTime.Now;
                }
                DS.DataSource.Orders.Add(order);
            }
            else
            {
                throw new SomeException("הימים תפוסים ולא ניתן לבצע את ההזמנה");
            }
        }
Exemple #2
0
        public void addOrder(BE.Order order)
        {
            BE.GuestRequest tmp = rGuest(order);
            if (tmp == null)
            {
                throw new SomeException("לא קיים אורח כזה  ");
            }
            BE.HostingUnit tmp2 = rHosting(order);
            if (tmp2 == null)
            {
                throw new SomeException("אין יחידת אירוח כזאת ");
            }

            if (order.Status == BE.StatusGuest.נשלח_מייל && tmp2.Owner.CollectionClearance)
            {
                order.OrderDate = DateTime.Now;
            }
            else if (tmp2.Owner.CollectionClearance == false && order.Status == BE.StatusGuest.נשלח_מייל)
            {
                throw new SomeException("איו אפשרות לשלוח מייל אם אין הרשאה לחיוב חשבון ");
            }
            else
            {
                IDAL.addOrder(order);
            }
        }
        public static BE.HostingUnit Clone(this BE.HostingUnit original)
        {
            BE.HostingUnit target = new BE.HostingUnit();
            target.Owner                = original.Owner;
            target.Area                 = original.Area;
            target.HostingUnitName      = original.HostingUnitName;
            target.HostingUnitKey       = original.HostingUnitKey;
            target.NumOfRooms           = original.NumOfRooms;
            target.NumOfBeds            = original.NumOfBeds;
            target.pool                 = original.pool;
            target.Jacuzzi              = original.Jacuzzi;
            target.Garden               = original.Garden;
            target.AirConditioner       = original.AirConditioner;
            target.ChildrensAttractions = original.ChildrensAttractions;
            target.Type                 = original.Type;
            target.Hikes                = original.Hikes;
            DateTime time = DateTime.Today, time2 = DateTime.Today.AddMonths(11);

            while (time < time2)
            {
                target[time] = original[time];
                time         = time.AddDays(1);
            }

            return(target);
        }
        /// <summary>
        /// add order to date base
        /// </summary>
        /// <param name="order"></param>
        public void addOrder(BE.Order or)
        {
            BE.GuestRequest tmp = null;

            tmp = rGuest(or);

            BE.HostingUnit tmp2 = rHosting(or);
            int            days = (tmp.ReleaseDate - tmp.EntryDate).Days;

            int price = (BE.Configuration.Commission * days);

            or.Commission = price;
            if (ApproveRequest(tmp, tmp2))
            {
                //סימון במטריצה
                Approve(tmp, tmp2);

                DataSource.Orders.Add(or);
            }
            else
            {
                throw new Exception("הימים תפוסים ולא ניתן לבצע את ההזמנה");
            }

            XMLHandler.GetXMLHandler().SaveToXML(DataSource.Orders, XMLHandler.GetXMLHandler().OrderPath);
            XMLHandler.GetXMLHandler().SaveToXML(DataSource.HostingUnits, XMLHandler.GetXMLHandler().HostingUnitPath);
        }
        /// <summary>
        /// check if dates available to order
        /// </summary>
        private bool IsDateArmor(BE.HostingUnit hostingUnit, DateTime entryDate, int count)
        {
            // get day and month, value between 0 and 30.
            int month = entryDate.Month - 1, day = entryDate.Day - 1;

            bool[,] diary = hostingUnit.Diary;

            if (diary[month, day] == false)
            {
                // in release day - diary[release day] = false
                // don't even check release day 'cause it doesn't matter
                for (int i = 0; i < count; ++i, ++day)
                {
                    if (day == BE.Configuration._days) // check if we in end of month
                    {
                        // past to next month
                        day = 0;
                        month++;
                        if (month == BE.Configuration._month) // check if we in end of year
                        {
                            month = 0;
                        }
                    }
                    // check for exists busy day
                    if (diary[month, day] == true)
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
 public void UpdateCalendar(BE.HostingUnit hostingUnit, DateTime entryDate, DateTime releaseDate)
 {
     if (IsDateArmor(hostingUnit, entryDate, releaseDate))
     {
         int month = entryDate.Month - 1,
             day   = entryDate.Day - 1;
         bool[,] diary = hostingUnit.Diary;
         int count = Count2Diary(entryDate, releaseDate);
         for (int i = 0; i < count; i++, ++day)
         {
             if (day == BE.Configuration._days) // check if we in end of month
             {
                 // past to next month
                 day = 0;
                 month++;
                 if (month == BE.Configuration._month) // check if we in end of year
                 {
                     month = 0;
                 }
             }
             diary[month, day] = true;
         }
         hostingUnit.Diary = diary; // update the data structer
         _dal.UpdateHostingUnit(hostingUnit);
     }
     else
     {
         throw new Exception("Dates already taken in this hosting unit");
     }
 }
Exemple #7
0
 /// <summary>
 /// adds a hosting unit
 /// </summary>
 /// <param name="unit"></param>
 public void AddHostingUnit(BE.HostingUnit unit)
 {
     try
     {
         if (dalAccess.GetHostingUnitList().Any(x => x.HostingUnitKey == unit.HostingUnitKey))
         {
             throw new InvalidOperationException(string.Format("Hosting Unit " + unit.HostingUnitKey + " already exists"));
         }
         var isValid = new EmailAddressAttribute().IsValid(unit.Owner.MailAddress);
         if (!isValid)
         {
             throw new InvalidOperationException("invalid email address");
         }
         if (unit.Owner.Age > 120)
         {
             throw new InvalidOperationException("invaild age");
         }
         if (unit.Floors < 0)
         {
             throw new InvalidOperationException("invaild amount of floors");
         }
         if (unit.Size < 0)
         {
             throw new InvalidOperationException("invaild size");
         }
         dalAccess.AddHostingUnit(unit);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #8
0
 /// <summary>
 /// deletes a hosting unit
 /// </summary>
 /// <param name="unit"></param>
 public void DeleteHostingUnit(BE.HostingUnit unit)
 {
     try
     {
         var it = from newUnit in dalAccess.GetHostingUnitList()
                  let x = newUnit.HostingUnitKey
                          where x == unit.HostingUnitKey
                          select new { HostingUnitKey = x };
         if (it == null)
         {
             throw new NullReferenceException(string.Format("Hosting Unit " + unit.HostingUnitKey + " doesn't exist"));
         }
         //if (dalAccess.GetOrderList().Any(y => y.HostingUnitKey == unit.HostingUnitKey && (y.Status != OrderStatus.customer_canceled)))
         //    throw new InvalidOperationException("cannot delete a hosting unit with active orders");
         foreach (var order in GetOrderList())
         {
             if (order.HostingUnitKey == unit.HostingUnitKey && order.Status != OrderStatus.customer_canceled)
             {
                 throw new InvalidOperationException("cannot delete a hosting unit with active orders");
             }
         }
         dalAccess.DeleteHostingUnit(unit);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #9
0
        private void hostsUnitsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            unit = hostUnits.SelectedItem as HostingUnit;
            IEnumerable <GuestRequest> temp4 = bl.RelevantRequest(unit);

            requests.ItemsSource = temp4;
        }
Exemple #10
0
        public void updateHostingUnit(BE.HostingUnit hostUnit)
        {
            if (hostUnit.HostingUnitKey == 0)                            //זה אומר שאין קוד ייחודי שהרי הערך לא מאותחל על ברירת מחדל
            {
                hostUnit.HostingUnitKey = BE.Configuration.geustReqID++; //הענק לו קוד ייחודי
            }
            ds.getHostingUnitList().RemoveAll(x => x.HostingUnitKey == hostUnit.HostingUnitKey);
            addHostingUnit(hostUnit.Clone());


            //עדכון כללי כאן.

            //var obj = ds.getHostingUnitList().FirstOrDefault(x => x.HostingUnitKey == hostUnit.HostingUnitKey);
            //if (obj != null) obj = hostUnit;
            //else if (obj == null)            //אם איו מופע כנ"ל משמע שלא מצא אותו ברשימה
            //{
            //    throw new KeyNotFoundException(string.Format("Hosting Unit  {0} not exsits in getHostingUnitList data ", hostUnit));
            //}

            ////מחיקת קודם ונעדכן חדש...
            //var itemToRemove = ds.getHostingUnitList().SingleOrDefault(r => r.HostingUnitKey == hostUnit.HostingUnitKey);
            //if (itemToRemove != null)
            //{
            //    ds.getHostingUnitList().Remove(itemToRemove); //מחיקת הערך
            //    ds.getHostingUnitList().Add(hostUnit.Clone()); // עדכון חדש

            //}
        }
Exemple #11
0
        public GRuserControlForAddOrder(BE.GuestRequest guesty, long key1, long hostkey)
        {
            InitializeComponent();
            if (hebEnglish.hebrew)
            {
                hebChange();
            }
            key2              = key1;
            hostkey1          = hostkey;
            gr                = guesty;
            hu                = bl.GetHostingUnitByKey(key2);
            grid1.DataContext = guesty;
            order             = new BE.Order();


            client = new SmtpClient()
            {
                Port                  = 587,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Host                  = "smtp.gmail.com",
                EnableSsl             = true,
                Credentials           = credentials
            };
        }
Exemple #12
0
        public static BE.HostingUnit Clone(this BE.HostingUnit original)
        {
            BE.HostingUnit target = new BE.HostingUnit(original.Owner, original.Area, original.HostingUnitName, original.Hostingunitkey, original.Diary);


            return(target);
        }
        //שליחת מייל
        private void mail_click(object sender, RoutedEventArgs e)
        {
            MailMessage mail = new MailMessage();

            BE.Order order    = (BE.Order)((Button)sender).DataContext;
            string   HostMail = "*****@*****.**";// BL.BL_imp.loggedInUser.Email;

            BE.GuestRequest guest        = bl.ReadAllGuestRequest().Where(x => x.GuestRequestKey == order.GuestRequestKey).FirstOrDefault();
            string          GuestMail    = guest.MailAddress;
            string          PasswordMail = "hhhaaalll";//BL.BL_imp.loggedInUser.Password;

            mail.To.Add(GuestMail);
            mail.From    = new MailAddress(HostMail);
            mail.Subject = "הצעת ארוח ממערכת גן עדן";
            BE.HostingUnit hostingUnit = bl.ReadHostingUnit(order.HostingUnitKey);
            mail.Body       = GetMailBody(guest, hostingUnit);
            mail.IsBodyHtml = true;

            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential(HostMail, PasswordMail);
            smtp.EnableSsl             = true;
            try
            {
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "שגיאה", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ChangeStatus(order);
        }
Exemple #14
0
        public static HostingUnit Clone(this HostingUnit original)
        {
            HostingUnit target = new BE.HostingUnit();

            target.HostingUnitKey       = original.HostingUnitKey;
            target.Owner                = original.Owner.Clone();
            target.area                 = original.area;
            target.type                 = original.type;
            target.Size                 = original.Size;
            target.Floors               = original.Floors;
            target.pool                 = original.pool;
            target.jacuzzi              = original.jacuzzi;
            target.wifi                 = original.wifi;
            target.tv                   = original.tv;
            target.garden               = original.garden;
            target.childrensAttractions = original.childrensAttractions;
            target.publicTransportation = original.publicTransportation;
            target.view                 = original.view;
            target.smoking              = original.smoking;
            target.roomService          = original.roomService;
            target.snackBar             = original.snackBar;
            target.HostingUnitName      = original.HostingUnitName;
            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 31; j++)
                {
                    target.Diary[i, j] = original.Diary[i, j];
                }
            }
            // target.Diary = original.Diary;
            return(target);
        }
Exemple #15
0
        public AddHostingUnit(BE.Host ho)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            bl          = FactoryBL.GetBl();
            hostingUnit = new BE.HostingUnit();
            BE.Host host = ho;
            this.DataContext = hostingUnit;

            errorMessages = new List <string>();

            //this.HostId.ItemsSource = bl.GetHostList();
            //this.HostId.DisplayMemberPath = "HostKey";
            //this.HostId.SelectedValuePath = "HostKey";

            this.HostId.Text = host.HostKey.ToString();

            this.Area.ItemsSource = Enum.GetValues(typeof(Enums.Area));
            this.Type.ItemsSource = Enum.GetValues(typeof(Enums.HostingUnitType));
            this.Food.ItemsSource = Enum.GetValues(typeof(Enums.Food));

            this.Pool.Text                = "No";
            this.Jacuzzi.Text             = "No";
            this.Porch.Text               = "No";
            this.ChildrenAttractions.Text = "No";
        }
Exemple #16
0
 private void allDatails_Click(object sender, RoutedEventArgs e)
 {
     BE.HostingUnit val = HostingUnitGrid.SelectedItem as BE.HostingUnit;
     if (val != null)
     {
         MessageBox.Show($"Datails of Hosting Unit: \n{val}", "all Datails", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
 private void HostingUnitKey_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.HostingUnitKey.SelectedItem is BE.HostingUnit)
     {
         this.hostingUnit = ((BE.HostingUnit) this.HostingUnitKey.SelectedItem);
         //setHostingUnitFields();
     }
 }
Exemple #18
0
 /// <summary>
 /// add Hosting Unit to date base
 /// </summary>
 /// <param name="host"></param>
 public void addHostingUnit(BE.HostingUnit hostingunit)
 {
     if (hostingunit.HostingUnitName == null)
     {
         throw new SomeException("חובה למלא שם");
     }
     hostingunit.Owner.numHostingUnit++;
     IDAL.addHostingUnit(hostingunit);
 }
 public HostingUnitUC(HostMenu caller, BE.HostingUnit hu)
 {
     InitializeComponent();
     this.hu            = hu;
     this.caller        = caller;
     Name.Content       = hu.HostingUnitName;
     Key.Content        = hu.HostingUnitKey.ToString();
     Commission.Content = hu.Commission.ToString();
 }
Exemple #20
0
 private void hComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (hComboBox.SelectedIndex == -1)
     {
         return;
     }
     hostingUnit          = hostingUnitKeys[hComboBox.SelectedIndex];
     order.HostingUnitKey = hostingUnit.HostingUnitKey;
 }
        public int ApprovedCount(BE.HostingUnit hostingUnit)
        {
            IEnumerable <BE.Order> orders = from order in _dal.GetAllOrders()
                                            where order.GuestRequestKey == hostingUnit.HostingUnitKey &&
                                            (order.Status == BE.Enums.Status.Approved || order.Status == BE.Enums.Status.MailSent)
                                            select order;

            return(orders.Count());
        }
 //סגירת עיסקה
 private bool check(BE.HostingUnit item, GuestRequest guest)
 {
     if ((item.area == guest.area) && (item.subArea == guest.subArea) && (Equal_(item.childrensAttractions, guest.childrensAttractions) &&
                                                                          (Equal_(item.DisabledAccessible, guest.DisabledAccessible)) && (Equal_(item.WindowToTheSea, guest.WindowToSea)) && (Equal_(item.ThereIsPool, guest.pool)) &&
                                                                          (Equal_(item.jacuzzi, guest.jacuzzi))))
     {
         return(true);
     }
     return(false);
 }
        public bool IsPossibleToDelete(BE.HostingUnit hostingUnit)
        {
            List <BE.Order> orders = _dal.GetAllOrders();
            // get all open orders who belong to the given hostingUnit
            IEnumerable <BE.Order> belongsTo = from order in orders
                                               where (order.HostingUnitKey == hostingUnit.HostingUnitKey && !IsOrderClose(order))
                                               select order;

            return(belongsTo.Count() == 0);
        }
        public bool IsDateArmor(BE.HostingUnit hostingUnit, DateTime entryDate, DateTime releaseDate)
        {
            if (!Ischronological(entryDate, releaseDate))
            {
                return(false);
            }
            int count = Count2Diary(entryDate, releaseDate);

            return(IsDateArmor(hostingUnit, entryDate, count));
        }
Exemple #25
0
        /// <summary>
        /// Remove Hosting Unit
        /// </summary>
        /// <param name="H"></param>
        public void RemoveHostingUnit(BE.HostingUnit H)
        {
            int count = HostingUnitsList.RemoveAll(HostU => HostU.HostingUnitKey == H.HostingUnitKey);

            if (count == 0)
            {
                throw new MissingException("HostingUnitKey");
            }
            SaveToXML <List <BE.HostingUnit> >(HostingUnitsList, HostingUnitsPath);
        }
 /// <summary>
 /// apdate Hosting Unit to date base
 /// </summary>
 /// <param name="hostingunit"></param>
 public void apdateHostingUnit(BE.HostingUnit hostingunit)
 {
     for (int i = 0; i < DS.DataSource.HostingUnits.Count; i++)
     {
         if (DS.DataSource.HostingUnits[i].Hostingunitkey == hostingunit.Hostingunitkey)
         {
             DS.DataSource.HostingUnits[i] = hostingunit;
         }
     }
 }
Exemple #27
0
        public void updateHostingUnit(BE.HostingUnit hostUnit)
        {
            BE.HostingUnit beforeChangeHostUnit = getHostingUnitByID(hostUnit.HostingUnitKey);
            //אם לא הושלם מילוי
            if (/*hostUnit.Owner == null ||*/ hostUnit.HostingUnitName == "" ||
                hostUnit.Owner.PrivateName == "" || hostUnit.Owner.FamilyName == "" ||
                hostUnit.Owner.PhoneNumber == "" || hostUnit.Owner.MailAddress == null ||
                hostUnit.Owner.BankBranchDetails == null || hostUnit.Owner.BankAccountNumber == 0)
            {
                throw new ArgumentException("חובה למלא את כל השדות");
            }
            if (!ValidateID(hostUnit.Owner.HostKey))
            {
                throw new System.IO.InvalidDataException("תעודת זהות של מארח לא תקינה.");
            }
            if (!Enum.IsDefined(typeof(BE.Enums.AreaEnum), hostUnit.Area))
            {
                throw new System.IO.InvalidDataException("Enum input illegal");
            }
            if (hostUnit.Area == BE.Enums.AreaEnum.All)
            {
                throw new System.IO.InvalidDataException("Enum input illegal. HostingUnit cannot be in All regions");
            }

            if (hostUnit.Type == BE.Enums.TypeEnum.Unknown)
            {
                throw new System.IO.InvalidDataException("חובה להגיד סוג יחידת אירוח");
            }


            if (beforeChangeHostUnit.Owner.CollectionClearance.Equals("Yes") && (hostUnit.Owner.CollectionClearance.Equals("No")))//אם רוצה לשנות הרשאת חשבון בנק
            {
                var checkOrder = from item in GetOrderList()
                                 where (item.HostingUnitKey == hostUnit.HostingUnitKey) &&
                                 ((item.Status == BE.Enums.StatusEnum.טרם_טופל) ||
                                  (item.Status == BE.Enums.StatusEnum.נשלח_מייל))
                                 select item;

                foreach (var item in checkOrder)
                {
                    throw new System.ArgumentException("לא ניתן לבטל הראשאת חיוב חשבון כל עוד יש הזמנה פתוחה");
                }
            }

            // after we cheek all the possible problems we can transfer the data to DAL layer

            try
            {
                IDAL.updateHostingUnit(hostUnit /*.Clone()*/);
            }
            catch (KeyNotFoundException e)
            {
                throw e;
            }
        }
Exemple #28
0
        public void updateHostingUnit(BE.HostingUnit hostUnit)
        {
            if (hostUnit.HostingUnitKey == 0)                                   //זה אומר שאין קוד ייחודי שהרי הערך לא מאותחל על ברירת מחדל
            {
                hostUnit.HostingUnitKey = BE.Configuration.GetHostingUnitKey(); //הענק לו קוד ייחודי
            }
            HostingUnitList1.RemoveAll(x => x.HostingUnitKey == hostUnit.HostingUnitKey);
            addHostingUnit(hostUnit.Clone());

            //BE.Tools.SaveToXML<List<HostingUnit>>(HostingUnitList1, BE.Tools.HostingUnitPath);
        }
Exemple #29
0
 /// <summary>
 /// returns the number of orders the requested unit has
 /// </summary>
 /// <param name="unit"></param>
 /// <returns></returns>
 public int NumberOfUnitOrders(BE.HostingUnit unit)
 {
     try
     {
         return(dalAccess.GetOrderList().Count(y => y.HostingUnitKey == unit.HostingUnitKey));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #30
0
 /// <summary>
 /// returns the number of successful orders a hosting unit has
 /// </summary>
 /// <param name="unit"></param>
 /// <returns></returns>
 public int NumberOfSuccessfullOrders(BE.HostingUnit unit)
 {
     try
     {
         return(dalAccess.GetOrderList().Count(y => y.HostingUnitKey == unit.HostingUnitKey && y.Status == OrderStatus.customer_accepted));
     }
     catch (Exception e)
     {
         throw e;
     }
 }