Beispiel #1
0
        public BookingsOnPropertyViewModel Build(int id)
        {
            var aProperty = _context.Properties
                            .Where(p => p.Id == id)
                            .Include(x => x.Bookings)
                            .SingleOrDefault();

            var bookings = aProperty.Bookings ?? new List <Booking>();


            return(new BookingsOnPropertyViewModel
            {
                HasBookings = bookings.Any(),
                Bookings = bookings.Select(x => new BookingViewModel
                {
                    Id = x.Id,
                    ViewingAt = x.ViewingAt,

                    IsRequested = x.Status == (int)BookingStatus.Requested,
                    Status = (BookingStatus)x.Status,

                    Property = null
                }),
                Property = PropertiesViewModelBuilder.MapViewModel(aProperty)
            });
        }
Beispiel #2
0
        public BookingViewModel Build(int id)
        {
            var property = _context.Properties.Find(id);

            return(new BookingViewModel
            {
                Status = BookingStatus.Requested,
                Property = PropertiesViewModelBuilder.MapViewModel(property),
                ViewingAt = DateTime.Now.ToUniversalTime()
            });
        }
        public OffersViewModel Build(PropertiesQuery query, string buyerUserId)
        {
            List <Offer> offers = _context.Offers.Where(o => o.BuyerUserId == buyerUserId).ToList();


            if (!string.IsNullOrWhiteSpace(query.Search))
            {
                //TODO:
            }

            return(new OffersViewModel
            {
                Offers = offers.Select(o => new OfferViewModel()
                {
                    Amount = o.Amount,
                    Status = ((OfferStatus)o.Status).ToString(),
                    Property = PropertiesViewModelBuilder.MapViewModel(o.ProperyRef)
                }).ToList(),
                Search = query.Search
            });
        }