Example #1
0
        public async Task <IActionResult> Add(RentalAddDto addDto)
        {
            var result = await _rentalService.AddAsync(_mapper.Map <Rental>(addDto));

            if (result.Success)
            {
                return(Created("", result));
            }
            return(BadRequest(result));
        }
Example #2
0
        public async Task <IActionResult> AddAsync(RentalAddDto rentalCreateDto)
        {
            var result = await _rentalService.AddAsync(rentalCreateDto);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("FriendId,GameId,Id")] Rental rental)
        {
            if (ModelState.IsValid)
            {
                await _rentalService.AddAsync(rental);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FriendId"] = new SelectList(friends, "Id", "Id", rental.FriendId);
            ViewData["GameId"]   = new SelectList(games, "Id", "Id", rental.GameId);
            return(View(rental));
        }