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)); } }
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)); } }
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)); } }
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)); } }
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)); } }