Esempio n. 1
0
        public async Task <IActionResult> GetAll()
        {
            var request = new GetAllAssociationRequest();
            var result  = await _mediatorService.Send(request);

            return(Ok(result));
        }
        public async Task <IActionResult> Create(CreateBoardGameDto input)
        {
            var newGuid = Guid.NewGuid();
            await _mediatorService.Send(new AddBoardGameCommand(newGuid, input.Name, input.Price));

            return(new OkObjectResult(new { newGuid }));
        }
        public async Task <IActionResult> Create(CreateClientDto input)
        {
            var newGuid = Guid.NewGuid();
            await _mediatorService.Send(new AddClientCommand(newGuid, input.FirstName, input.LastName,
                                                             input.ContactNumber, input.EmailAddress));

            return(new OkObjectResult(new { newGuid }));
        }
        public async Task <IList <RentalDay> > Handle(GetRentalDaysQuery request, CancellationToken cancellationToken)
        {
            if (request.RentFinishDate == null)
            {
                request.RentFinishDate = _dateTimeProvider.UtcNow;
            }

            var oneDayRentPrice = await _mediatorService.Send(new GetBoardGameRentDayPriceQuery(request.BoardGamePrice),
                                                              cancellationToken);

            var passedTime = request.RentFinishDate - request.RentStartDate;
            var passedDays = passedTime.Value.Days;

            if (passedTime.Value.Minutes >= 1)
            {
                passedDays++;
            }

            IList <RentalDay> rentDays = new List <RentalDay>();

            for (var i = 0; i < passedDays; i++)
            {
                rentDays.Add(new RentalDay(oneDayRentPrice, request.RentStartDate.AddDays(i).Date));
            }

            return(rentDays);
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(CreateRentalDto input)
        {
            var newGuid = Guid.NewGuid();
            await _mediatorService.Send(new AddRentalCommand(newGuid, input.ClientGuid, input.BoardGameGuid,
                                                             input.ChargedDeposit));

            return(new OkObjectResult(new { newGuid }));
        }
        public async Task <RentalWithPaymentDetails> Handle(GetRentalWithPaymentDetailsQuery request,
                                                            CancellationToken cancellationToken)
        {
            var rentalWithDetails =
                await _mediatorService.Send(new GetRentalWithDetailsQuery(request.RentalGuid), cancellationToken);

            if (rentalWithDetails == null)
            {
                throw new RentalNotFoundException(request.RentalGuid);
            }

            var rentalWithPaymentDetails = _mapper.Map <RentalWithPaymentDetails>(rentalWithDetails);

            rentalWithPaymentDetails.RentalDays = await _mediatorService.Send(
                new GetRentalDaysQuery(rentalWithDetails.BoardGame.Price, rentalWithDetails.CreationTime),
                cancellationToken);

            rentalWithPaymentDetails.MoneyToPay = rentalWithPaymentDetails.RentalDays.Sum(x => x.AmountDue);
            return(rentalWithPaymentDetails);
        }
 public async Task <IEnumerable <TodoList> > GetLists([FromQuery] GetTodoListsQuery query)
 {
     return(await _mediatorService.Send <GetTodoListsQuery, IEnumerable <TodoList> >(query));
 }
Esempio n. 8
0
 protected async Task <TResult> QueryAsync <TResult>(IRequest <TResult> query)
 {
     return(await _mediatorService.Send(query));
 }
Esempio n. 9
0
        public async Task <IActionResult> Authenticate(AuthenticateUserRequest request)
        {
            var result = await _mediatorService.Send(request);

            return(Ok(result));
        }
Esempio n. 10
0
        public async Task <WeatherForecast> Get([FromQuery] GetWeatherForecastsQuery query)
        {
            var result = await _mediatorService.Send <GetWeatherForecastsQuery, WeatherForecast>(query);

            return(result);
        }
Esempio n. 11
0
        public async Task <ActionResult> FindAnagrams([FromQuery] FindAnagramsViewModel findAnagramsViewModel)
        {
            var findAnagramRequest = Map <FindAnagramsViewModel, FindAnagramRequest>(findAnagramsViewModel);

            return(Ok(await _mediatorService.Send <FindAnagramRequest, FindAnagramResponse>(findAnagramRequest)));
        }