예제 #1
0
            public async Task <IEnumerable <UserActivityDto> > Handle(Query request, CancellationToken cancellationToken)
            {
                IEnumerable <DataModel.Activity> dbResult = await _unitOfWork.UserActivityRepo.GetUserActivities(request.AppUserId, request.Predicate, cancellationToken);

                var result = _mapperHelper.MapList <DataModel.Activity, UserActivityDto>(dbResult);

                return(result?.OrderBy(a => a.Date));
            }
예제 #2
0
            public Task <object> Handle(Command command, CancellationToken cancellationToken)
            {
                IEnumerable <Domain.Item> list = _mapperHelper.MapList <SaveList.Command.Item, Domain.Item>(command.List);

                _unitOfWork.ItemRepo.Save(list);
                _unitOfWork.Commit();
                object response = new
                {
                    Inserted = command.List.Where(c => c.Version == default).Count(),
                    Updated  = command.List.Where(c => c.Version != default).Count()
                };

                return(Task.FromResult(response));
            }

            #endregion
        }
예제 #3
0
            public Task <ResponseEnvelope <Dto.Item> > Handle(Query request, CancellationToken cancellationToken)
            {
                Expression <Func <Domain.Item, bool> > predicate = (item
                                                                    => string.IsNullOrWhiteSpace(request.NameLike) ||
                                                                    item.Name.ToLower().Contains(request.NameLike.ToLower()));

                IEnumerable <Domain.Item> dbResponse = _unitOfWork.ItemRepo.Find(predicate, request.Offset, request.Limit, request.OrderBy, request.OrderByDesc);
                int count = _unitOfWork.ItemRepo.Count(predicate);

                return(Task.FromResult
                       (
                           new ResponseEnvelope <Dto.Item>
                {
                    Count = count,
                    List = _mapperHelper.MapList <Domain.Item, Dto.Item>(dbResponse)
                }
                       ));
            }
예제 #4
0
        private async Task <IEnumerable <ActivityDto> > Prepare(IEnumerable <DataModel.Activity> dbActivities)
        {
            IEnumerable <ActivityDto> activities = _mapperHelper.MapList <DataModel.Activity, ActivityDto>(dbActivities);

            if (activities?.Any() == true)
            {
                IEnumerable <Guid>         attendees     = activities.SelectMany(a => a.Attendees.Select(a => a.AppUserId)).Distinct();
                IEnumerable <UserFollower> followingList = await _unitOfWork
                                                           .UserFollowerRepo
                                                           .FindAsync(u => attendees.Contains(u.UserId) && u.FollowerId == _userAccessor.GetCurrentUserId());

                foreach (var activity in activities)
                {
                    foreach (var attendee in activity.Attendees)
                    {
                        attendee.Following = followingList.Any(u => u.UserId == attendee.AppUserId);
                    }
                }
            }
            return(activities);
        }
예제 #5
0
            public Task <IEnumerable <Dto.Item> > Handle(Query request, CancellationToken cancellationToken)
            {
                IEnumerable <Domain.Item> dbResponse = _unitOfWork.ItemRepo.GetAll();

                return(Task.FromResult(_mapperHelper.MapList <Domain.Item, Dto.Item>(dbResponse)));
            }
예제 #6
0
            public async Task <IEnumerable <CommentDto> > Handle(Command request, CancellationToken cancellationToken)
            {
                IEnumerable <DataModel.Comment> dbComments = await _unitOfWork.CommentRepo.FindAsync(request.ActivityId, cancellationToken);

                return(_mapperHelper.MapList <DataModel.Comment, CommentDto>(dbComments));
            }