public void Handle(BookViewingCommand command) { var viewing = new Viewing { Appointment = command.Appointment, PropertyId = command.PropertyId, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, BuyerUserId = command.BuyerUserId }; _context.Viewings.Add(viewing); _context.SaveChanges(); }
public void Handle(BookViewingCommand command) { var property = _context.Properties.Find(command.Property_Id); var booking = new Viewing { dateTimeBooking = command.dateTimeBooking, userId = command.userId, status = ViewingStatus.Pending, }; if (property.Viewings == null) { property.Viewings = new List <Viewing>(); } property.Viewings.Add(booking); _context.SaveChanges(); }