Exemplo n.º 1
0
        public override User Find(object keyValue)
        {
            var includes = new IncludeList <User>(x => x.Address);
            var user     = _repository.Find(includes, keyValue);

            return(UserCleanup(user));
        }
Exemplo n.º 2
0
        public virtual async Task <PagedList <TEntity> > GetAsync <TKey>(
            Expression <Func <TEntity, bool> > filter,
            Expression <Func <TEntity, TKey> > order,
            int page,
            int itemsPerPage,
            IncludeList <TEntity> includes)
        {
            var skip  = (page - 1) * itemsPerPage;
            var query = _dbSet.AsQueryable();

            if (includes != null)
            {
                foreach (var item in includes)
                {
                    query = query.Include(item);
                }
            }

            query = query.Where(filter);
            var total = await query.CountAsync();

            var result = await query
                         .OrderBy(order)
                         .Skip(skip)
                         .Take(itemsPerPage)
                         .ToListAsync();

            return(new PagedList <TEntity>()
            {
                Page = page,
                ItemsPerPage = itemsPerPage,
                TotalItems = total,
                Items = result
            });
        }
Exemplo n.º 3
0
        public async Task SendEmailBookDonor(BookUser bookUser)
        {
            var includeList = new IncludeList <Book>(x => x.User);

            //obtem o livro requisitado e o usuário doador do livro
            var bookRequested = _bookService.Find(includeList, bookUser.BookId);

            //obter o endereço do usuario que solicitou o livro
            var donatedUser = this._userService.Find(bookUser.UserId);
            var vm          = new
            {
                Request         = bookUser,
                Book            = bookRequested,
                DonatedLocation = GenerateDonatedLocation(donatedUser),
                Donor           = new
                {
                    Name       = bookRequested.User.Name,
                    ChooseDate = string.Format("{0:dd/MM/yyyy}", bookRequested.ChooseDate.Value)
                },
                RequestingUser = new { NickName = $"Interessado {bookRequested.TotalInterested()}" },
            };

            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookNoticeDonorTemplate, vm);

            await _emailService.Send(bookRequested.User.Email, bookRequested.User.Name, html, BookNoticeDonorTitle);
        }
Exemplo n.º 4
0
        public async Task<TEntity> FindAsync(IncludeList<TEntity> includes, params object[] keyValues)
        {
            var result = await _dbSet.FindAsync(keyValues);

            if (includes != null)
                foreach (var item in includes)
                    await _context.Entry(result).Reference(item).LoadAsync();

            return result;
        }
Exemplo n.º 5
0
        private void InclusiveFileOp(string source, string backupDir, string target, Action <string, string> fileOp)
        {
            var backupTarget = Path.Join(backupDir, target);

            var entries = Directory.EnumerateFileSystemEntries(source);

            if (IncludeList != null)
            {
                entries = entries.Intersect(IncludeList.Select(t => Path.Join(source, t)));
            }

            PerformFileOperations(fileOp, backupTarget, entries);
        }
Exemplo n.º 6
0
        public async Task<TEntity> FindAsync(IncludeList<TEntity> includes, Expression<Func<TEntity, bool>> filter)
        {
            var query = _dbSet.AsQueryable();

            if (includes != null)
                foreach (var item in includes)
                    query = query.Include(item);

            query = query.Where(filter);

            var count = await query.CountAsync();
            if (count > 1)
                throw new TransferServiceException("More than one entity find for the specified filter");

            return query.FirstOrDefault();
        }
Exemplo n.º 7
0
        public async Task SendEmailBookRequested(BookUser bookUser)
        {
            var includeList   = new IncludeList <Book>(x => x.User);
            var bookRequested = _bookService.Find(includeList, bookUser.BookId);

            var requestingUser = _userService.Find(bookUser.UserId);

            var vm = new
            {
                Request        = bookUser,
                Book           = bookRequested,
                RequestingUser = requestingUser,
            };
            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookRequestedTemplate, vm);

            await _emailService.SendToAdmins(html, BookRequestedTitle);
        }
Exemplo n.º 8
0
        public async Task SendEmailBookDonor(BookUser bookUser)
        {
            var includeList   = new IncludeList <Book>(x => x.User);
            var bookRequested = _bookService.Find(includeList, bookUser.BookId);
            var vm            = new
            {
                Request = bookUser,
                Book    = bookRequested,
                Donor   = new
                {
                    Name       = bookRequested.User.Name,
                    ChooseDate = string.Format("{0:dd/MM/yyyy}", bookRequested.ChooseDate.Value)
                },
                RequestingUser = new { NickName = $"Interessado {bookRequested.TotalInterested()}" },
            };

            var html = await _emailTemplate.GenerateHtmlFromTemplateAsync(BookNoticeDonorTemplate, vm);

            await _emailService.Send(bookRequested.User.Email, bookRequested.User.Name, html, BookNoticeDonorTitle);
        }
Exemplo n.º 9
0
        public bool ShouldDownload(Torrent item)
        {
            if (Enabled)
            {
                if (!DownloadedTorrents.Contains(item))
                {
                    string       title  = Utils.RemoveDiacritics(IgnoreCaps ? item.Title.ToLower() : item.Title);
                    RegexOptions option = IgnoreCaps ? RegexOptions.IgnoreCase : RegexOptions.None;

                    if (Regex.IsMatch(title, RegexPattern, option))
                    {
                        if (IncludeList.All(title.Contains))
                        {
                            if (!ExcludeList.Any(title.Contains))
                            {
                                if (IsTV)
                                {
                                    if (item.IsTV)
                                    {
                                        if (IsEpisodeToDownload(item))
                                        {
                                            return(true);
                                        }
                                    }
                                }
                                else
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 10
0
 public TEntity Find(IncludeList <TEntity> includes, params object[] keyValues) => FindAsync(includes, keyValues).Result;
Exemplo n.º 11
0
 public TEntity Find(IncludeList <TEntity> includes, Expression <Func <TEntity, bool> > filter) => _repository.Find(includes, filter);
Exemplo n.º 12
0
 public virtual TEntity Find(IncludeList <TEntity> includes, object keyValue)
 => _repository.Find(includes, keyValue);
Exemplo n.º 13
0
 public PagedList <TEntity> Get <TKey>(Expression <Func <TEntity, TKey> > order, int page, int itemsPerPage, IncludeList <TEntity> includes)
 => Get(x => true, order, page, itemsPerPage, includes);
Exemplo n.º 14
0
 public PagedList <TEntity> Get <TKey>(Expression <Func <TEntity, bool> > filter, Expression <Func <TEntity, TKey> > order, int page, int itemsPerPage, IncludeList <TEntity> includes)
 => GetAsync(filter, order, page, itemsPerPage, includes).Result;
Exemplo n.º 15
0
 public PagedList <TEntity> Get <TKey>(Expression <Func <TEntity, bool> > filter, Expression <Func <TEntity, TKey> > order, IncludeList <TEntity> includes)
 => Get(filter, order, 1, int.MaxValue, includes);
Exemplo n.º 16
0
 public TEntity Find(IncludeList <TEntity> includes, Expression <Func <TEntity, bool> > filter) => FindAsync(includes, filter).Result;
Exemplo n.º 17
0
 public TEntity Find(IncludeList <TEntity> includes, object keyValue) => FindAsync(includes, keyValue).Result;
Exemplo n.º 18
0
 public PagedList <TEntity> Get <TKey>(Expression <Func <TEntity, TKey> > order, IncludeList <TEntity> includes)
 => _repository.Get(order, includes);
Exemplo n.º 19
0
 public PagedList <TEntity> Get <TKey>(Expression <Func <TEntity, bool> > filter, Expression <Func <TEntity, TKey> > order, int page, int itemsPerPage, IncludeList <TEntity> includes)
 => _repository.Get(filter, order, page, itemsPerPage, includes);