public async Task <int> Create(Meso meso) { meso.UserId = _identity.GetUserId(); _context.Add(meso); await _context.SaveChangesAsync(); return(meso.Id); }
protected override async Task Handle(AddOpinionForDriverCommand request, CancellationToken cancellationToken) { var driver = await _driversRepository.GetByIdAsync(request.DriverId); driver.AddOpinion(request.Value, request.Description, _identityProvider.GetUserId()); await _unitOfWork.SaveAsync(); }
public override Task OnConnectedAsync() { Groups.AddToGroupAsync(Context.ConnectionId, _identityProvider.GetRole()); Groups.AddToGroupAsync(Context.ConnectionId, _identityProvider.GetUserId()); return(base.OnConnectedAsync()); }
protected override async Task Handle(SetDefaultPaymentMethodCommand request, CancellationToken cancellationToken) { var customer = await _customersRepository.GetAsync(_identityProvider.GetUserId()); customer.SetDefaultPaymentMethod(request.PaymentMethodId); await _unitOfWork.SaveAsync(); }
public async Task <RideDto> Handle(GetCurrentRideQuery request, CancellationToken cancellationToken) { var ride = await _ridesRepository.GetCurrentCustomerRideAsync(_identityProvider.GetUserId()); if (ride is null) { throw new ResourceDoesNotExistException(typeof(Ride)); } return(_mapper.Map <RideDto>(ride)); }
public async Task <Guid> Handle(AddPaymentMethodCommand request, CancellationToken cancellationToken) { var customer = await _customersRepository.GetAsync(_identityProvider.GetUserId()); var paymentMethod = _mapper.Map <PaymentMethod>(request); customer.AddPaymentMethod(paymentMethod); await _unitOfWork.SaveAsync(); return(paymentMethod.Id); }
public async Task <Guid> Handle(OrderRideCommand request, CancellationToken cancellationToken) { var userId = _identityProvider.GetUserId(); var ride = await _rideFactory.CreateRideAsync(userId, request.Address, request.Latitude, request.Longitude, request.CouponCode); await _ridesRepository.AddRideAsync(ride); await _unitOfWork.SaveAsync(); return(ride.Id); }
protected override async Task Handle(PickUpRideCommand request, CancellationToken cancellationToken) { var userId = _identityProvider.GetUserId(); var driver = await _driversRepository.GetByIdAsync(userId); var ride = await _ridesRepository.GetByIdAsync(request.RideId); ride.AssignDriver(driver); ride.Version = request.Version; await _unitOfWork.SaveAsync(); }
public virtual Task InsertAsync(TCollection document) { document.UserId = _identityProvider.GetUserId(); return(Collection.InsertOneAsync(document)); }
public async Task <IEnumerable <PaymentMethodDto> > Handle(GetPaymentMethodsQuery request, CancellationToken cancellationToken) { var customer = await _customersRepository.GetAsync(_identityProvider.GetUserId()); return(_mapper.Map <IEnumerable <PaymentMethodDto> >(customer.PaymentMethods)); }
public async Task <IEnumerable <RideDto> > Handle(GetUnpaidRidesQuery request, CancellationToken cancellationToken) { var unpaidRides = await _customersRepository.GetUnpaidRidesAsync(_identityProvider.GetUserId()); return(_mapper.Map <IEnumerable <RideDto> >(unpaidRides)); }
private static void AppendUserInfoToRequest(DownstreamRequest request, IIdentityProvider identityProvider) { request.Headers.Add(Constants.UserIdHeaderKey, identityProvider.GetUserId().ToString()); request.Headers.Add(Constants.UsernameHeaderKey, identityProvider.getUsername()); }
protected Guid UserId() { return(_identityProvider.GetUserId()); }
public async Task <dynamic> GetMuscleGroupBreakdown(int mesoId) { var muscleGroupsWithCount = await _context.MuscleGroupCount.FromSql($"SELECT MuscleGroupId, COUNT(*) AS Count FROM Exercises e INNER JOIN Mesocycles m ON e.MesoId = m.Id WHERE m.UserId = '{_identity.GetUserId()}' AND m.Id = {mesoId} GROUP BY MuscleGroupId").ToListAsync(); var allMuscleGroups = (int[])Enum.GetValues(typeof(MuscleGroup)); muscleGroupsWithCount.AddRange(allMuscleGroups. Where(x => !muscleGroupsWithCount.Any(y => y.MuscleGroupId == x)) .Select(z => new MuscleGroupCount { MuscleGroupId = z, Count = 0 })); return(muscleGroupsWithCount.Select(x => new { Name = Enum.GetName(typeof(MuscleGroup), x.MuscleGroupId), x.Count }).ToList()); }