public EventModel(Event @event, bool isFromReports = false, RoundAgeReportFilter filterValue = RoundAgeReportFilter.None, bool isActualEvent = true) { _event = @event; _eventType = _event.EventType; _eventStatus = _event.EventStatus; EventUpdates = new ObservableCollection <EventUpdate>(); EventItems = new ObservableCollection <EventItemModel>(); EventNotes = new ObservableCollection <EventNoteModel>(); EventCharges = new ObservableCollection <EventChargeModel>(); EventItemsWithNotes = new ObservableCollection <EventItemModel>(); EventContacts = new ObservableCollection <EventContact>(); Correspondences = new ObservableCollection <CorrespondenceModel>(); Reports = new ObservableCollection <ReportModel>(); EventReminders = new ObservableCollection <EventReminderModel>(); if (isFromReports) { EventPayments = new ObservableCollection <EventPaymentModel>(_event.EventPayments.Select(x => new EventPaymentModel(x))); EventCaterings = new List <EventCateringModel>(_event.EventCaterings.Select(x => new EventCateringModel(x))); EventGolfs = new List <EventGolfModel>(_event.EventGolfs.Where(eventGolf => !eventGolf.IsLinked).Select(x => new EventGolfModel(x))); EventRooms = new List <EventRoomModel>(_event.EventRooms.Select(x => new EventRoomModel(x))); EventInvoices = new List <EventInvoiceModel>(_event.EventInvoices.Select(x => new EventInvoiceModel(x))); EventBookedProducts = new List <EventBookedProductModel>(_event.EventBookedProducts.Select(x => new EventBookedProductModel(x))); EventNotes = new ObservableCollection <EventNoteModel>(_event.EventNotes.Select(x => new EventNoteModel(x))); SetEventPriceForReports(filterValue); UpdatePaymentDetails(); Days = DateTime.Now - Event.Date; } else { EventPayments = new ObservableCollection <EventPaymentModel>(); EventCaterings = new List <EventCateringModel>(); EventRooms = new List <EventRoomModel>(); EventGolfs = new List <EventGolfModel>(); EventInvoices = new List <EventInvoiceModel>(); EventBookedProducts = new List <EventBookedProductModel>(); } Documents = new List <Document>(); if (_event.Contact != null) { PrimaryContact = new ContactModel(_event.Contact); } LoadedTime = DateTime.Now; RefreshChanges(); IsActualEvent = isActualEvent; IsGroupDateVisible = true; }
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; } }
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; }
public EventModel(Event @event, bool isFromReports = false, RoundAgeReportFilter filterValue = RoundAgeReportFilter.None, bool isActualEvent = true) { _event = @event; _eventType = _event.EventType; _eventStatus = _event.EventStatus; EventUpdates = new ObservableCollection<EventUpdate>(); EventItems = new ObservableCollection<EventItemModel>(); EventNotes = new ObservableCollection<EventNoteModel>(); EventCharges = new ObservableCollection<EventChargeModel>(); EventItemsWithNotes = new ObservableCollection<EventItemModel>(); EventContacts = new ObservableCollection<EventContact>(); Correspondences = new ObservableCollection<CorrespondenceModel>(); Reports = new ObservableCollection<ReportModel>(); EventReminders = new ObservableCollection<EventReminderModel>(); if (isFromReports) { EventPayments = new ObservableCollection<EventPaymentModel>(_event.EventPayments.Select(x => new EventPaymentModel(x))); EventCaterings = new List<EventCateringModel>(_event.EventCaterings.Select(x => new EventCateringModel(x))); EventGolfs = new List<EventGolfModel>(_event.EventGolfs.Where(eventGolf => !eventGolf.IsLinked).Select(x => new EventGolfModel(x))); EventRooms = new List<EventRoomModel>(_event.EventRooms.Select(x => new EventRoomModel(x))); EventInvoices = new List<EventInvoiceModel>(_event.EventInvoices.Select(x => new EventInvoiceModel(x))); EventBookedProducts = new List<EventBookedProductModel>(_event.EventBookedProducts.Select(x => new EventBookedProductModel(x))); EventNotes = new ObservableCollection<EventNoteModel>(_event.EventNotes.Select(x => new EventNoteModel(x))); SetEventPriceForReports(filterValue); UpdatePaymentDetails(); Days = DateTime.Now - Event.Date; } else { EventPayments = new ObservableCollection<EventPaymentModel>(); EventCaterings = new List<EventCateringModel>(); EventRooms = new List<EventRoomModel>(); EventGolfs = new List<EventGolfModel>(); EventInvoices = new List<EventInvoiceModel>(); EventBookedProducts = new List<EventBookedProductModel>(); } Documents = new List<Document>(); if (_event.Contact != null) PrimaryContact = new ContactModel(_event.Contact); LoadedTime = DateTime.Now; RefreshChanges(); IsActualEvent = isActualEvent; IsGroupDateVisible = true; }