public void Handle(BookViewingCommand command, string buyerId)
        {
            var property = _context.Properties.Find(command.PropertyId);

            if (property != null)
            {
                DateTime requestedDateTime = new DateTime(command.RequestedDate.Year,
                                                          command.RequestedDate.Month,
                                                          command.RequestedDate.Day,
                                                          command.RequestedTime.Hour,
                                                          command.RequestedTime.Minute,
                                                          0);
                var viewing = new Viewing
                {
                    RequestedDateTime = requestedDateTime,
                    BuyerUserId       = buyerId
                };

                if (property.Viewings == null)
                {
                    property.Viewings = new List <Viewing>();
                }

                property.Viewings.Add(viewing);

                _context.SaveChanges();
            }
        }
        public void Handle(BookViewingCommand command)
        {
            try
            {
                var property = _context.Properties.Find(command.PropertyId);

                var booking = new BookViewing
                {
                    Appointment = command.Appointment,
                    Status      = ViewingStatus.Pending,
                    CreatedAt   = DateTime.Now,
                    UpdatedAt   = DateTime.Now,
                    BuyerUserId = command.BuyerUserId,
                };

                if (property.BookViewings == null)
                {
                    property.BookViewings = new List <BookViewing>();
                }

                property.BookViewings.Add(booking);

                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
            }
        }
        public void Handle(BookViewingCommand command)
        {
            var viewvg = new Viewing
            {
                Date       = command.DateV,
                PropertyId = command.PropertyId,
                VisitorId  = command.VisitorId
            };

            _context.Viewings.Add(viewvg);

            _context.SaveChanges();
        }
        public void Handle(BookViewingCommand command)
        {
            var property = _context.Properties.Find(command.PropertyId);

            var viewing = new Viewing
            {
                ViewingAt  = command.ViewingAt,
                CreatedAt  = DateTime.Now,
                BuyerId    = command.BuyerId,
                PropertyId = command.PropertyId
            };

            _context.Viewings.Add(viewing);

            _context.SaveChanges();
        }
Ejemplo n.º 5
0
        public void Handle(BookViewingCommand command)
        {
            var property = _context.Properties.Find(command.PropertyId);

            var viewing = new Viewing
            {
                ViewingDate = command.ViewingDate,
                UserId      = command.UserId
            };

            if (property.Viewings == null)
            {
                property.Viewings = new List <Viewing>();
            }

            property.Viewings.Add(viewing);

            _context.SaveChanges();
        }
Ejemplo n.º 6
0
        public void Handle(BookViewingCommand command)
        {
            var property = context.Properties.Find(command.PropertyId);

            var viewing = new Viewing
            {
                ViewingTime = command.ViewingTime,
                Property    = property,
                UserId      = command.UserId,
                Status      = Status.Pending
            };

            if (property.Viewings == null)
            {
                property.Viewings = new List <Viewing>();
            }

            context.Viewings.Add(viewing);

            context.SaveChanges();
        }
Ejemplo n.º 7
0
        public void Handle(BookViewingCommand command)
        {
            var property = _context.Properties.Find(command.PropertyId);

            // TODO: last chance to look for double bookings.
            var viewing = new Viewing
            {
                AppointmentTime = command.Appointment,
                BuyerId         = command.BuyerId
            };

            if (property.Viewings == null)
            {
                property.Viewings = new List <Viewing>();
            }

            property.Viewings.Add(viewing);

            // as part of this a notification should be sent to the seller, and comfirmation sent to the buyer
            _context.SaveChanges();
        }
        public void Handle(BookViewingCommand command)
        {
            var property = _context.Properties.Find(command.PropertyId);

            var viewing = new Viewing
            {
                Name        = command.Name,
                Phone       = command.Phone,
                Email       = command.Email,
                BookingTime = command.BookingTime,
                CreatedAt   = DateTime.Now,
                BuyerUserId = command.BuyerUserId
            };

            if (property.Viewings == null)
            {
                property.Viewings = new List <Viewing>();
            }

            property.Viewings.Add(viewing);

            _context.SaveChanges();
        }