Exemplo n.º 1
0
        public void UpdatingOrder(Order order, Enums.OrderStatus status)
        {
            int index = OrderList.FindIndex(c => c.OrderKey == order.OrderKey);

            if (index > -1)
            {
                OrderList[index].Status = status;

                if (status == Enums.OrderStatus.Success)
                {
                    //עדכון של שאר ההזמנות
                    var orders = OrderList.FindAll(c => c.GuestRequestKey == order.GuestRequestKey);
                    foreach (var orderi in orders)
                    {
                        orderi.Status = Enums.OrderStatus.Closed;
                    }

                    //עדכון הימים באכסניה

                    int         hostingid       = HostingUnitsList.FindIndex(c => c.stSerialKey == order.HostingUnitKey);
                    var         request         = GuestRequestList.Where(c => c.GuestRequestsKey == order.GuestRequestKey).FirstOrDefault();
                    HostingUnit relatedHostings = GetHostingUnits(c => c.stSerialKey == order.HostingUnitKey).FirstOrDefault();
                    Host        relatedHost     = GetHostById(relatedHostings.OwnerId);
                    var         settings        = GetGlobalSettings();
                    if (hostingid > -1 && request != null && relatedHost != null && settings != null)
                    {
                        // Diary diary = HostingUnitsList[hostingid].DiaryState;
                        for (DateTime time = request.EntryDate.AddDays(1); time < request.ReleaseDate; time = time.AddDays(1))
                        {
                            DaysList.Add(new FullDays()
                            {
                                Date          = time.Date,
                                HostingUnitId = order.HostingUnitKey,
                                OrderId       = order.OrderKey,
                                Id            = Configuration.DaysIdentity + 1
                            });
                            Configuration.DaysIdentity++;
                            relatedHost.Discount += settings.PayForDay;
                            relatedHostings.Totaldays++;


                            //diary.Calender[time.Month - 1, time.Day - 1] = true;
                        }
                        // HostingUnitsList[key].DiaryState = diary;
                    }
                    OrderList[index].Status = Enums.OrderStatus.Success; //אני לא יודעת אם סטטוס ההזמנה המקורית השנה אף הוא
                }
                UpdateXml <Order>(OrderList);
                UpdateXml <FullDays>(DaysList);
                UpdateXml <Host>(HostsList);
            }
        }
Exemplo n.º 2
0
        public List <GuestRequest> GetGuestRequests(Func <GuestRequest, bool> predicate = null)
        {
            //update unrelevant request to expired
            var expired_requests = GuestRequestList.Where(c => c.EntryDate < DateTime.Now && (c.StatusId == 0 /*open*/ || c.StatusId == 1 /*inproccess*/)).ToList();

            if (expired_requests.Count > 0)
            {
                foreach (var expired_request in expired_requests)
                {
                    UpdatingGusetRequest(expired_request, Enums.GuestRequestStatus.Expired);
                }
            }
            if (predicate != null)
            {
                return(GuestRequestList.Where(predicate).ToList());
            }
            else
            {
                return(GuestRequestList);
            }
        }