Exemple #1
0
        public async Task <IActionResult> Lend([FromBody] Lending lending)
        {
            if (lending == null)
            {
                return(BadRequest("Lending data not passed"));
            }

            string modelValidationError;

            if (!lending.IsValid(out modelValidationError))
            {
                return(BadRequest(modelValidationError));
            }


            var lentGames = await _lendingRepository.Lend(lending);

            if (lentGames == null)
            {
                return(NotFound($"Friend with Id {lending.Friend} doesn't exist"));
            }

            return(Ok(lentGames));
        }