Exemple #1
0
        public async ValueTask <ApiResponse <List <BasicBike> > > GetAvailableBikes()
        {
            try
            {
                var allBikess = await BikeService.GetAvailableBikes();

                return(ApiUtils.CreateSuccessResponse(allBikess));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                return(ApiUtils.CreateErrorResponse <List <BasicBike> >(ex));
            }
        }
Exemple #2
0
        public async ValueTask <ApiResponse <BasicBike> > Post([FromBody] BasicBike bike)
        {
            try
            {
                var orderedBike = await BikeService.OrderAsync(bike);

                return(ApiUtils.CreateSuccessResponse(orderedBike));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                return(ApiUtils.CreateErrorResponse <BasicBike>(ex));
            }
        }
Exemple #3
0
        public async ValueTask <ApiResponse <Dictionary <Guid, IList <BasicBike> > > > Get()
        {
            try
            {
                var allBikess = await BikeService.AllBikesOrderedAsync();

                return(ApiUtils.CreateSuccessResponse(allBikess));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                return(ApiUtils.CreateErrorResponse <Dictionary <Guid, IList <BasicBike> > >(ex));
            }
        }
Exemple #4
0
        public async ValueTask <ApiResponse <IList <BasicBike> > > Get(Guid userId)
        {
            try
            {
                var userBikes = await BikeService.BikesOrderedByUserAsync(userId);

                return(ApiUtils.CreateSuccessResponse(userBikes));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                return(ApiUtils.CreateErrorResponse <IList <BasicBike> >(ex));
            }
        }
Exemple #5
0
        public async ValueTask <ApiResponse <List <UserOrder> > > Get()
        {
            try
            {
                var allBikes = await BikeService.AllBikesOrderedAsync();

                var result = allBikes.Keys.Select(x => new UserOrder(x, allBikes[x])).ToList();
                return(ApiUtils.CreateSuccessResponse(result));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                return(ApiUtils.CreateErrorResponse <List <UserOrder> > (ex));
            }
        }