示例#1
0
        public async Task <bool> AuthorizeUserAsync(string username, string password)
        {
            var userResult = await userQueryObject.ExecuteQuery(new UserFilterDTO { UserName = username });

            var user = userResult.Items.SingleOrDefault();

            var succ = user != null && VerifyHashedPassword(user.PasswordHash, user.PasswordSalt, password);

            return(succ);
        }
示例#2
0
 public async Task <IDictionary <int, double> > GetUsersWithAvgRatings()
 {
     return((await ListAllAsync()).Items
            .Join(userQueryObject.ExecuteQuery(new UserFilterDto()).Result.Items,
                  userReview => userReview.ReviewedUserID,
                  user => user.Id,
                  (review, user) => new { User = user, Evaluation = review.Evaluation })
            .GroupBy(join => join.User.Id)
            .ToDictionary(group => group.Key,
                          group => Math.Round(((double)group.Select(review => review.Evaluation).Sum() /
                                               group.Select(review => review.Evaluation).Count()), 1)));
 }
        public async Task <List <OrderWithFullDependencyDto> > GetUnclosedOrdersOfCompany(int companyId)
        {
            var queryResult = await queryIsClosed.ExecuteQuery(new OrderClosedFilterDto { CompanyId = companyId, IsClosed = false });

            List <OrderWithFullDependencyDto> orders = new List <OrderWithFullDependencyDto>();

            foreach (var result in queryResult.Items)
            {
                orders.Add(Mapper.Map <OrderWithFullDependencyDto>(await Repository.GetAsync(result.Id, nameof(Order.Items))));
            }

            return(orders);
        }
        public async Task <(bool success, string role)> AuthorizeUserAsync(string email, string password)
        {
            var userResult = await _query.ExecuteQuery(new EmployeeFilterDto()
            {
                Email = email
            });

            var user = userResult.Items.SingleOrDefault();

            var succ = user != null && VerifyHashedPassword(user.PasswordHash, user.PasswordSalt, password);
            var role = user?.Role.ToString() ?? "";

            return(succ, role);
        }
示例#5
0
        public async Task <UserDto> GetUserAccordingToUsernameAsync(string username)
        {
            var queryResult = await userQueryObject.ExecuteQuery(new UserFilterDto { Username = username });

            return(queryResult.Items.SingleOrDefault());
        }
        public async Task <UserProfileUserDto> GetUserProfileUserByNickNameAsync(string nickName)
        {
            var queryResult = await _userProfileUserQueryObject.ExecuteQuery(new UserFilterDto { NickName = nickName });

            return(queryResult?.Items.SingleOrDefault());
        }
 /// <summary>
 /// Gets all DTOs (for given type)
 /// </summary>
 /// <returns>all available dtos (for given type)</returns>
 public virtual async Task <QueryResultDto <TDto, TFilterDto> > ListAllAsync()
 {
     return(await Query.ExecuteQuery(new TFilterDto()));
 }
示例#8
0
        public async Task <List <OrderItemWithMenuItemDto> > GetWithMenuItemByOrderId(int id)
        {
            var queryResult = await QueryWithMenuItemByOrder.ExecuteQuery(new OrderItemFilterByOrderDto { OrderId = id });

            return(queryResult == null ? new List <OrderItemWithMenuItemDto>() : queryResult.Items.ToList());
        }
示例#9
0
        public async Task <List <OrderItemDto> > GetByOrderId(int id)
        {
            var queryResult = await QueryByOrder.ExecuteQuery(new OrderItemFilterByOrderDto { OrderId = id });

            return(queryResult.Items.ToList());
        }