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); } }
public void DeleteHostingUnit(int hostingUnitId) { int index = HostingUnitsList.FindIndex(c => c.stSerialKey == hostingUnitId); if (index > -1) { HostingUnitsList.RemoveAt(index); //delete Prev items GalleryList.RemoveAll(c => c.HostingUnitId == hostingUnitId); } UpdateXml <HostingUnit>(HostingUnitsList); UpdateXml <GalleryImageItem>(GalleryList); }