예제 #1
0
        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);
        }
예제 #2
0
 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));
 }