public OfferId Create(DateTime from, DateTime to, string apartmentIdString, decimal priceDecimal, string ownerIdString, decimal depositDecimal) { var apartmentId = ApartmentId.From(apartmentIdString); var apartment = _apartmentRepository.Get(apartmentId); var period = Period.From(from, to); var pricePerDay = Price.From(priceDecimal); var ownerId = OwnerId.From(ownerIdString); var deposit = Price.From(depositDecimal); var offer = OfferFactory.Create(apartment, ownerId, period, pricePerDay, deposit); _offerRepository.Save(offer); return(offer.Id); }
public void Add(CreateApartmentDto createApartmentDto) { var address = Address.From(createApartmentDto.StreetName, createApartmentDto.PostalCode); var ownerId = OwnerId.From(createApartmentDto.OwnerId); var rooms = new List <Room>(); foreach (var(area, type) in createApartmentDto.Rooms) { var room = Room.From(area, type); rooms.Add(room); } var apartment = ApartmentFactory.Create(address, ownerId, rooms); _apartmentRepository.Save(apartment); }