Ejemplo n.º 1
0
 public static bool updateProgress(Progression progress)
 {
     //processing
     return(ProgressionRepository.UpdateProgress(progress));
     //validating
     //TODO
 }
Ejemplo n.º 2
0
        public ProgressionSearch SortByDate()
        {
            var now   = DateTime.Now;
            var model = new ProgressionSearch
            {
                EndDate   = now,
                StartDate = now.AddDays(-90)
            };
            var progressions = ProgressionRepository
                               .GetList(p => p.Date >= model.StartDate && p.Date <= model.EndDate)
                               .Select(SProgression.DtoS)
                               .ToList();

            model.Progressions = progressions;

            var books = BookRepository.GetAll();

            books.Insert(0, null);
            model.Books = new SelectList(books, "Id", "Title");
            var statuses = StatusRepository.GetAll();

            statuses.Insert(0, null);
            model.Statuses = new SelectList(statuses, "Id", "Title");

            return(model);
        }
Ejemplo n.º 3
0
 public static Progression getProgress(int AccountID)
 {
     //processing
     return(ProgressionRepository.getProgress(AccountID));
     //validating
     //TODO
 }
Ejemplo n.º 4
0
        public UserDetails GetDetails(string userId)
        {
            DUser user        = UserRepository.GetSingle(userId);
            var   userDetails = new UserDetails {
                User = user
            };
            var progressions = ProgressionRepository.GetList(p => p.UserId == user.Id);
            var books        = progressions.Select(p => p.Book).ToList();

            userDetails.ProgressionSections =
                (from p in progressions
                 orderby p.Book.Title
                 group p by p.Book.Id into g
                 select new ProgressionSection
            {
                Book = books.First(b => b.Id == g.Key).Title,
                BookId = g.Key,
                Progressions = g.Select(SProgression.DtoS).ToList()
            }).ToList();

            var notes = NoteRepository.GetList(p => p.UserId == user.Id);

            userDetails.NoteSections =
                (from p in notes
                 group p by p.Book.Title into g
                 select new NoteByBook
            {
                Book = g.Key,
                Notes = g.Select(SNote.DtoS).ToList()
            }).ToList();
            return(userDetails);
        }
Ejemplo n.º 5
0
        public IList <BookList> GetListByStatus(string userId, Func <Progression, bool> filter)
        {
            var books        = BookRepository.GetAll();
            var progressions = ProgressionRepository
                               .GetList(p => p.UserId == userId)
                               .OrderBy(p => p.Date)
                               .ToList();

            progressions =
                (from progression in progressions
                 group progression by progression.BookId
                 into g
                 where filter(g.Last())
                 select g.Last()
                ).ToList();
            var bookModels =
                (from book in books
                 join progression in progressions on book.Id equals progression.BookId
                 select new BookList
            {
                Id = book.Id,
                Status = progression.Status,
                Title = book.Title,
                Category = book.Category.Title,
                NumberOfPages = book.NumberOfPages,
                ReleaseDate = book.ReleaseDate,
                Progression = progression
            }).ToList();

            bookModels = bookModels.OrderByDescending(b => b.Progression.Date).ToList();
            return(bookModels);
        }
Ejemplo n.º 6
0
        public IList <BookList> GetList(string userId)
        {
            var books        = BookRepository.GetAll();
            var progressions = ProgressionRepository.GetList(b => b.UserId == userId);

            progressions =
                (from progression in progressions
                 group progression by progression.BookId
                 into g
                 select g.First()
                ).ToList();
            var bookModels =
                (from book in books
                 let progression = progressions.FirstOrDefault(p => p.BookId == book.Id)
                                   select new BookList
            {
                Id = book.Id,
                Status = progression != null ? progression.Status : new Status {
                    Title = "N/A"
                },
                Title = book.Title,
                Category = book.Category.Title,
                NumberOfPages = book.NumberOfPages,
                ReleaseDate = book.ReleaseDate
            }).ToList();

            return(bookModels);
        }
Ejemplo n.º 7
0
 public bool UpdateProgression(Progression progress)
 {
     if (progress == null)
     {
         return(false);
     }
     return(ProgressionRepository.UpdateProgress(progress));
 }
Ejemplo n.º 8
0
        public List <SProgression> GetByBook(string userId, Guid bookId)
        {
            var progressions = ProgressionRepository
                               .GetList(p => p.UserId == userId && p.BookId == bookId)
                               .Select(SProgression.DtoS)
                               .ToList();

            return(progressions);
        }
Ejemplo n.º 9
0
        public void UnBookMark(string userId, Guid bookId)
        {
            var bookmarkStatus = StatusRepository.GetSingle(s => s.Title == "Bookmarked");
            var progression    = ProgressionRepository.GetSingle(
                p => p.StatusId == bookmarkStatus.Id &&
                p.BookId == bookId &&
                p.UserId == userId
                );

            ProgressionRepository.Delete(progression.Id);
        }
Ejemplo n.º 10
0
        public List <SProgression> Search(ProgressionSearch search)
        {
            var progressions = ProgressionRepository
                               .GetList(p =>
                                        (search.BookId == null || p.BookId == search.BookId) &&
                                        (search.StatusId == null || p.StatusId == search.StatusId) &&
                                        p.Date >= search.StartDate && p.Date <= search.EndDate)
                               .Select(SProgression.DtoS)
                               .ToList();

            return(progressions);
        }
Ejemplo n.º 11
0
        public void BookMark(string userId, Guid bookId)
        {
            var bookmarkStatus = StatusRepository.GetSingle(s => s.Title == "Bookmarked");
            var progression    = new Progression
            {
                BookId   = bookId,
                StatusId = bookmarkStatus.Id,
                UserId   = userId,
                Date     = DateTime.Now
            };

            ProgressionRepository.Add(progression);
        }
Ejemplo n.º 12
0
        public List <ProgressionSection> SortByBook(string userId)
        {
            var progressions        = ProgressionRepository.GetList(p => p.UserId == userId);
            var books               = progressions.Select(p => p.Book);
            var progressionSections =
                (from p in progressions
                 orderby p.Book.Title
                 group p by p.Book.Id into g
                 select new ProgressionSection
            {
                Book = books.First(b => b.Id == g.Key).Title,
                BookId = g.Key,
                Progressions = g.Select(SProgression.DtoS).ToList()
            }).ToList();

            return(progressionSections);
        }
Ejemplo n.º 13
0
 public void Delete(Guid id)
 {
     ProgressionRepository.Delete(id);
 }
Ejemplo n.º 14
0
 public void Update(SProgression entity)
 {
     ProgressionRepository.Update(SProgression.StoD(entity));
 }
Ejemplo n.º 15
0
 public void Add(SProgression entity)
 {
     ProgressionRepository.Add(SProgression.StoD(entity));
 }
Ejemplo n.º 16
0
        public SProgression GetSingle(Guid id)
        {
            var progression = ProgressionRepository.GetSingle(id);

            return(SProgression.DtoS(progression));
        }