public async Task <StatusCodeResult> Put(ulong apartmentId, Models.SaveApartment saveApartment, CancellationToken cancellationToken) { var res = await this.mediator.Send(new UpdateApartment(apartmentId, Map(saveApartment, await this.GetRealtorId(saveApartment.RealtorId, cancellationToken))), cancellationToken); return(res.Match <StatusCodeResult>(success => this.Ok(), _ => this.NotFound())); }
private static Apartment Map(Models.SaveApartment apt, ulong realtorId) { return(new Apartment(0, apt.Name, apt.Description, apt.FloorArea, apt.PricePerMonth, apt.NumberOfRooms, apt.Lat, apt.Lon, DateTime.UtcNow, realtorId, apt.IsRented)); }
public async Task <ulong> Post(Models.SaveApartment saveApartment, CancellationToken cancellationToken) { return(await this.mediator.Send(new AddApartment(Map(saveApartment, await this.GetRealtorId(saveApartment.RealtorId, cancellationToken))), cancellationToken)); }