예제 #1
0
        public override async Task <ReservationDto> InsertReservation(ReservationDto request, ServerCallContext context)
        {
            try
            {
                var reservation = request.ConvertToEntity();
                var response    = await _manager.AddEntity(reservation);

                return(response.ConvertToDto());
            }
            catch (Exception e)
            {
                if (e is InvaildDateRangException)
                {
                    throw new RpcException(new Status(StatusCode.OutOfRange, e.Message));
                }

                if (e is AutoUnavailableException)
                {
                    throw new RpcException(new Status(StatusCode.ResourceExhausted, e.Message));
                }
                throw new RpcException(new Status(StatusCode.Internal, "Internal error occured."));
            }
        }