public void Handle(BookAppointmentCommand command) { var property = _context.Properties.Find(command.PropertyId); if (property != null) { var appointment = new Appointment { Property_Id = command.PropertyId, AppointmentDateTime = command.AppointmentDateTime, BuyerUserId = command.BuyerUserId, Status = AppointmentStatus.Accepted, // as of now it will be accepted, but it needs to be pending by default and appointment should be accepted by seller/agent in future CreatedAt = DateTime.Now, }; if (property.Appointments == null) { property.Appointments = new List <Appointment>(); } property.Appointments.Add(appointment); _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(MakeOfferCommand command) { var property = _context.Properties.Find(command.PropertyId); if (property != null) { var offer = new Offer { Amount = command.Offer, Status = OfferStatus.Pending, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, BuyerUserId = command.BuyerUserId }; if (property.Offers == null) { property.Offers = new List <Offer>(); } property.Offers.Add(offer); _context.SaveChanges(); } }
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 bool Handle(MakeOfferCommand command) { var property = _context.Properties.Find(command.PropertyId); if (property.Offers != null && property.Offers.Count(o => o.BuyerUserId == command.BuyerUserId) > 0) { return(false); } var offer = new Offer { Amount = command.Offer, Status = OfferStatus.Pending, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, BuyerUserId = command.BuyerUserId }; if (property.Offers == null) { property.Offers = new List <Offer>(); } property.Offers.Add(offer); _context.SaveChanges(); return(true); }
public bool Handle(BookAppointmentCommand command) { var property = _context.Properties.Find(command.PropertyId); //if (property.Appointments != null && property.Appointments.Count(o => o.BuyerUserId == command.BuyerUserId) > 0) { return false; } var appointment = new Appointment { PropertyId = command.PropertyId, ViewingDateTime = command.ViewingDateTime, BuyerUserId = command.BuyerUserId, IsViewing = true, UpdatedAt = DateTime.Now }; if (property.Appointments == null) { property.Appointments = new List <Appointment>(); } property.Appointments.Add(appointment); _context.SaveChanges(); return(true); }
public void Handle(ListPropertyCommand command) { var property = _context.Properties.Find(command.PropertyId); property.IsListedForSale = true; _context.SaveChanges(); }
public void Handle(RequestViewingCommand command) { var property = _context.Properties.Find(command.PropertyId); DateTime viewingDateTime = default(DateTime); DateTime.TryParseExact(string.Format("{0} {1}", command.ViewingDate, command.ViewingTime), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out viewingDateTime); var viewing = new Viewing { RequestDate = viewingDateTime, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, RequestUserId = command.RequestedUserId }; if (property.Viewings == null) { property.Viewings = new List <Viewing>(); } property.Viewings.Add(viewing); _context.SaveChanges(); }
public void Handle(RejectViewingCommand command) { var viewing = _context.Viewings.Find(command.ViewingId); viewing.ViewingStatus = ViewingStatus.Rejected; _context.SaveChanges(); }
public void Handle(AcceptViewingCommand command) { var viewing = _context.Viewings.Find(command.ViewingId); viewing.ViewingStatus = ViewingStatus.Confirmed; _context.SaveChanges(); }
public void Handle(RejectViewingCommand command) { var viewing = _context.BookViewings.Find(command.AppointmentId); viewing.UpdatedAt = DateTime.Now; viewing.Status = ViewingStatus.Rejected; _context.SaveChanges(); }
public void Handle(AcceptOfferCommand command) { var offer = _context.Offers.FirstOrDefault(o => o.Id == command.OfferId); offer.UpdatedAt = DateTime.Now; offer.Status = OfferStatus.Accepted; _context.SaveChanges(); }
public void Handle(AcceptViewingCommand command) { var viewing = _context.Viewings.Find(command.ViewingId); viewing.UpdatedAt = DateTime.Now; viewing.Status = ViewingStatus.Accepted; _context.SaveChanges(); }
public void Handle(RejectOfferCommand command) { var offer = _context.Offers.Find(command.OfferId); offer.UpdatedAt = DateTime.Now; offer.Status = Status.Rejected; _context.SaveChanges(); }
public void Handle(RejectViewingCommand command) { var viewing = _context.Viewings.FirstOrDefault(o => o.Id == command.ViewingId); viewing.UpdatedAt = DateTime.Now; viewing.Status = ViewingStatus.Rejected; _context.SaveChanges(); }
public void Handle(RejectAppointmentCommand command) { var appointment = _context.Appointments.Find(command.AppointmentId); appointment.UpdatedAt = DateTime.Now; appointment.Status = AppointmentStatus.Rejected; _context.SaveChanges(); }
public void Handle(RejectViewingCommand command) { var viewing = _context.Viewings.Find(command.ViewingId); if (viewing != null) { viewing.ViewingStatus = ViewingStatus.Declined; _context.SaveChanges(); } }
public void Save(BookingViewModel command, string buyerUserId) { var property = _context.Properties.Find(command.Property.Id); var aBooking = new Booking { Status = (int)BookingStatus.Requested, BuyerUserId = buyerUserId, ViewingAt = command.ViewingAt }; if (property.Bookings == null) { property.Bookings = new List <Booking>(); } property.Bookings.Add(aBooking); _context.SaveChanges(); }
public void Handle(AcceptOfferCommand command) { var offer = _context.Offers.Find(command.OfferId); var property = _context.Properties.Find(command.PropertyId); offer.UpdatedAt = DateTime.Now; offer.Status = OfferStatus.Accepted; property.IsListedForSale = false; _context.SaveChanges(); }
public void Handle(AcceptOfferCommand command) { var offer = _context.Offers.Find(command.OfferId); if (offer != null) { offer.UpdatedAt = DateTime.Now; offer.Status = OfferStatus.Accepted; _context.SaveChanges(); } }
/// <summary> /// Please use XML comments to state the expected behaviour or outcome (or reference the user story/Gherkin). /// This is particularly important if the controller actions are merely orchestrators i.e. they do not execute the business logic. /// </summary> /// <param name="command"></param> /// <remarks>This handler will raise an exception if the PropertyId is not found. /// This *is* the behaviour; however, is it the *correct* behaviour? Has this been discussed? Is it a conscious design decision? /// If so, how is this intent being communicated to me? You need to state this explicitly, or provide an additional UT that exercises this behaviour. /// </remarks> public void Handle(ListPropertyCommand command) { var property = _context.Properties.Find(command.PropertyId); // we have not defined behaviours for the case where the property is already listed // it may be that idempotency is desirable, and we can implement that here and also save a write to the DB if (!property.IsListedForSale) { property.IsListedForSale = true; _context.SaveChanges(); } }
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 viewing = new Viewing { Appointment = command.Appointment, PropertyId = command.PropertyId, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, BuyerUserId = command.BuyerUserId }; _context.Viewings.Add(viewing); _context.SaveChanges(); }
/// <summary> /// Updates the status of appointment. /// </summary> public void Handle(UpdateAppointmentCommand command) { var property = _context.Properties.Where(p => p.Id == command.PropertyId && p.SellerUserId == command.SellerUserId && p.Appointments.Any(a => a.Id == command.AppointmentId)) .Include(p => p.Appointments) .FirstOrDefault(); var appointment = property.Appointments.First(a => a.Id == command.AppointmentId); appointment.Status = command.NewStatus; _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(); }
public void Handle(CreatePropertyCommand command) { var property = new Domain.Models.Property { PropertyType = command.PropertyType, StreetName = command.StreetName, Description = command.Description, NumberOfBedrooms = command.NumberOfBedrooms }; property.SellerUserId = command.SellerUserId; _context.Properties.Add(property); _context.SaveChanges(); }
public void Handle(CreatePropertyCommand command) { var property = new Models.Property { PropertyType = command.PropertyType, StreetName = command.StreetName, Description = command.Description, NumberOfBedrooms = command.NumberOfBedrooms, IsListedForSale = true //Bug: Defaulting Property for sale to false }; property.SellerUserId = command.SellerUserId; _context.Properties.Add(property); _context.SaveChanges(); }
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(); }
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(); }
public void Handle(RequestAppointmentCommand command) { var property = _context.Properties.Find(command.PropertyId); var appt = new Appointment { Date = System.DateTime.Parse(command.AppointmentDate + " " + command.AppointmentTime), CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, BuyerUserId = command.BuyerUserId }; if (property.Appointments == null) { property.Appointments = new List <Appointment>(); } property.Appointments.Add(appt); _context.SaveChanges(); }