コード例 #1
0
        public async Task <IActionResult> UpdateCartridge(Guid id, CartridgeUpdateRequest request)
        {
            var result = await CartridgeService.UpdateCartridge(id, request);

            if (!result)
            {
                return(NotFound(ApiResponse.Failure("Update", $"Cartridge with id ${id} does not exist")));
            }

            return(Ok(ApiResponse.Success()));
        }
コード例 #2
0
        public async Task <IActionResult> Get(Guid id)
        {
            var result = await CartridgeService.GetEditDetails(id);

            if (result == null)
            {
                return(NotFound(ApiResponse.Failure("Cartridge", "Not Found")));
            }

            return(Ok(ApiResponse <CartridgeEditDetails> .Success(result)));
        }
コード例 #3
0
        public async Task <IActionResult> CartridgeForRent(Guid id)
        {
            var result = await CartridgeService.CartridgeForRent(id);

            if (result == null)
            {
                return(BadRequest(ApiResponse.Failure("Cartridge", "Not found")));
            }

            return(Ok(ApiResponse <CartridgeForRent> .Success(result)));
        }
コード例 #4
0
        public async Task <IActionResult> Create(CartridgeAddRequest request)
        {
            var movieDb = MovieService.GetMovie(request.MovieId, true);

            if (movieDb == null)
            {
                return(BadRequest(ApiResponse.Failure("Movie", $"Movie with id: {request.MovieId} does not exist")));
            }

            await CartridgeService.AddCartridge(request);

            return(Ok(ApiResponse.Success()));
        }
コード例 #5
0
        public async Task <IActionResult> CartridgeRentForm(Guid cartridgeId, Guid userId)
        {
            var result = await CartridgeService.CartridgeForRentForm(cartridgeId, userId);

            if (result == null)
            {
                return(NotFound(ApiResponse.Failure("Rental", "Cartride does not seem to exist")));
            }

            if (!result.UserCanBorrow)
            {
                return(BadRequest(ApiResponse.Failure("User", "User cannot borrow this cartridge")));
            }

            if (result.Avaible == 0)
            {
                return(BadRequest(ApiResponse.Failure("NoItems", "No avaible cartridge copise")));
            }

            return(Ok(ApiResponse <CartridgeRental> .Success(result)));
        }
コード例 #6
0
        public async Task <IActionResult> CartridgesForRent()
        {
            var result = await CartridgeService.CartridgesForRent();

            return(Ok(ApiResponse <IEnumerable <CartridgeForRentList> > .Success(result)));
        }