Exemplo n.º 1
0
        public void RefreshItems()
        {
            EventItems = new ObservableCollection <EventItemModel>();

            foreach (var eventCatering in EventCaterings)
            {
                eventCatering.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(
                    EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventCatering.EventCatering.ID));

                EventItems.Add(new EventItemModel()
                {
                    Instance                = eventCatering,
                    Note                    = eventCatering.EventCatering.Notes,
                    Room                    = eventCatering.Room.Name,
                    Time                    = new DateTime(0001, 1, 1, eventCatering.Time.Hour, eventCatering.Time.Minute, eventCatering.Time.Second),//eventCatering.StartTime,
                    Title                   = "Catering",
                    TotalPrice              = eventCatering.EventBookedProducts.Any() ? eventCatering.EventBookedProducts.Sum(y => y.TotalPrice) : 0,
                    Products                = new ObservableCollection <EventBookedProductModel>(eventCatering.EventBookedProducts),
                    ShowInInvoice           = eventCatering.EventCatering.ShowInInvoice,
                    IncludeInCorrespondence = eventCatering.EventCatering.IncludeInCorrespondence
                });
            }

            foreach (var eventRoom in EventRooms)
            {
                eventRoom.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(
                    EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventRoom.EventRoom.ID));

                EventItems.Add(new EventItemModel()
                {
                    Instance                = eventRoom,
                    Note                    = eventRoom.EventRoom.Notes,
                    Room                    = eventRoom.Room.Name,
                    Time                    = new DateTime(0001, 1, 1, eventRoom.StartTime.Hour, eventRoom.StartTime.Minute, eventRoom.StartTime.Second),
                    Title                   = "Room",
                    TotalPrice              = eventRoom.EventBookedProducts.Any() ? eventRoom.EventBookedProducts.Sum(y => y.TotalPrice) : 0,
                    Products                = new ObservableCollection <EventBookedProductModel>(eventRoom.EventBookedProducts),
                    ShowInInvoice           = eventRoom.EventRoom.ShowInInvoice,
                    IncludeInCorrespondence = eventRoom.EventRoom.IncludeInCorrespondence
                });
            }

            EventGolfs.ForEach(eventGolf =>
            {
                eventGolf.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventGolf.EventGolf.ID));

                EventItems.Add(new EventItemModel()
                {
                    Instance                = eventGolf,
                    Time                    = eventGolf.Time,
                    Note                    = eventGolf.EventGolf.Notes,
                    Title                   = "Golf",
                    TotalPrice              = eventGolf.EventBookedProducts.Any() ? eventGolf.EventBookedProducts.Sum(y => y.TotalPrice) : 0,
                    Products                = new ObservableCollection <EventBookedProductModel>(eventGolf.EventBookedProducts),
                    ShowInInvoice           = eventGolf.EventGolf.ShowInInvoice,
                    IncludeInCorrespondence = eventGolf.EventGolf.IncludeInCorrespondence
                });
            });

            EventInvoices.ForEach(eventInvoice =>
            {
                eventInvoice.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventInvoice.EventInvoice.ID));

                EventItems.Add(new EventItemModel()
                {
                    Instance                = eventInvoice,
                    Time                    = null,
                    Note                    = eventInvoice.EventInvoice.Notes,
                    Title                   = "Invoice",
                    TotalPrice              = eventInvoice.EventBookedProducts.Any() ? eventInvoice.EventBookedProducts.Sum(y => y.TotalPrice) : 0,
                    Products                = new ObservableCollection <EventBookedProductModel>(eventInvoice.EventBookedProducts),
                    ShowInInvoice           = eventInvoice.EventInvoice.ShowInInvoice,
                    IncludeInCorrespondence = eventInvoice.EventInvoice.IncludeInCorrespondence
                });
            });

            EventItems = new ObservableCollection <EventItemModel>(EventItems.OrderBy(eventItem => eventItem.Time ?? DateTime.MaxValue));

            // Used on Event Notes view
            EventItemsWithNotes = new ObservableCollection <EventItemModel>(_eventItems.Where(eventItemWithNotes => !string.IsNullOrWhiteSpace(eventItemWithNotes.Note)));

            RefreshEventStartEndTime();

            RefreshEventPrice();

            UpdatePaymentDetails();

            Days = DateTime.Now - Event.Date;

            RefreshResourceBookingsList();
        }
Exemplo n.º 2
0
 private void SetEventPriceForReports(RoundAgeReportFilter filterValue)
 {
     EventPrice = 0.0;
     if (filterValue == RoundAgeReportFilter.CateringOnly || filterValue == RoundAgeReportFilter.Both || filterValue == RoundAgeReportFilter.None)
     {
         foreach (var eventCatering in EventCaterings)
         {
             eventCatering.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventCatering.EventCatering.ID));
             EventPrice = EventPrice + (eventCatering.EventBookedProducts.Any() ? eventCatering.EventBookedProducts.Sum(y => y.TotalPrice) : 0);
         }
     }
     if (filterValue == RoundAgeReportFilter.GolfOnly || filterValue == RoundAgeReportFilter.Both || filterValue == RoundAgeReportFilter.None)
     {
         foreach (var eventGolf in EventGolfs)
         {
             eventGolf.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventGolf.EventGolf.ID));
             EventPrice = EventPrice + (eventGolf.EventBookedProducts.Any() ? eventGolf.EventBookedProducts.Sum(y => y.TotalPrice) : 0);
         }
     }
     if (filterValue == RoundAgeReportFilter.None)
     {
         foreach (var eventRoom in EventRooms)
         {
             eventRoom.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventRoom.EventRoom.ID));
             EventPrice = EventPrice + (eventRoom.EventBookedProducts.Any() ? eventRoom.EventBookedProducts.Sum(y => y.TotalPrice) : 0);
         }
         foreach (var eventInvoice in EventInvoices)
         {
             eventInvoice.EventBookedProducts = new ObservableCollection <EventBookedProductModel>(EventBookedProducts.Where(y => y.EventBookedProduct.EventBookingItemID == eventInvoice.EventInvoice.ID));
             EventPrice = EventPrice + (eventInvoice.EventBookedProducts.Any() ? eventInvoice.EventBookedProducts.Sum(y => y.TotalPrice) : 0);
         }
     }
     if (Double.IsNaN(EventPrice / Places) || Double.IsInfinity(EventPrice / Places))
     {
         EventPricePerPerson = 0;
     }
     else
     {
         EventPricePerPerson = EventPrice / Places;
     }
 }