public async override Task <AccommodationRepresentation> FindAccommodation(FindRequest request, ServerCallContext context) { var accommodation = await accommodationDataSource.FindAsync(request.Id); if (accommodation == null) { var metadata = new Metadata { { "Id", request.Id.ToString() } }; throw new RpcException(new Status(StatusCode.NotFound, "Accommodation not found"), metadata); } var result = new AccommodationRepresentation { Id = accommodation.Id, FacilityId = accommodation.FacilityId, Name = accommodation.Name, Description = accommodation.Description, RoomCount = accommodation.RoomCount }; result.Images.AddRange(accommodation.Images); return(result); }
public static Accommodation ToDomainModel(this AccommodationRepresentation accommodation) => new Accommodation { Id = accommodation.Id, Name = accommodation.Name, Description = accommodation.Description, FacilityId = accommodation.FacilityId, RoomCount = accommodation.RoomCount, Images = accommodation.Images?.ToArray() };
public Accommodation MapFrom(AccommodationRepresentation accommodation) => Mapper.Map <Accommodation>(accommodation);
public Accommodation MapFrom(AccommodationRepresentation accommodation) { return(Mapper.Map <Accommodation>(accommodation)); }