/// <summary>
        /// categorizes epics
        /// </summary>
        /// <param name="categoryID">Category Id</param>
        /// <param name="epicID">Epic Id</param>
        /// <returns>False if epic is already categorized or true if epic categorized successfully</returns>
        public bool CategorizeEpic(IEnumerable <Domain.Models.Category> categoriesToAdd, int epicID)
        {
            var dbEpicCatergory = _context.EpicCategories;

            if (dbEpicCatergory != null)
            {
                foreach (var category in categoriesToAdd)
                {
                    if (dbEpicCatergory.Find(epicID, category.ID) != null)
                    {
                        categoriesToAdd = categoriesToAdd.Where(c => c.ID != category.ID).ToList();
                    }
                }
            }
            if (categoriesToAdd.Count() == 0)
            {
                return(false);
            }

            foreach (var cat in categoriesToAdd)
            {
                var epicCategory = new EpicCategory
                {
                    EpicId     = epicID,
                    CategoryId = cat.ID
                };

                dbEpicCatergory.Add(epicCategory);
            }

            _context.SaveChanges();

            return(true);
        }
        public bool SubscribeToPublisher(int subscriberID, int publisherID)
        {
            var newSubscription = new Subscription {
                WriterId = publisherID, SubscriberId = subscriberID, HasNewContent = true
            };

            _context.Add(newSubscription);

            _context.SaveChanges();

            return(true);
        }
Example #3
0
 public bool UpdateEpic(Domain.Models.Epic epic)
 {
     try
     {
         var db_epic = _context.Epics.First(e => e.Id == epic.ID);
         db_epic.DateCompleted = epic.DateCompleted;
         db_epic.Name          = epic.Title;
         _context.SaveChanges();
         return(true);
     }
     catch { return(false); }
 }
        /// <summary>
        /// Create a user account
        /// </summary>
        /// <param name="user">user to add to database</param>
        /// <returns>True if user succesfully added to database or false if customer already exists</returns>
        public bool CreateAccount(Domain.Models.User user)
        {
            var dbUser = _context.Users.Include(r => r.RoleNavigation)
                         .FirstOrDefault(u => u.Id == user.ID);

            if (dbUser != null)
            {
                return(false);
            }

            _context.Users.Add(Mappers.UserMapper.MapBasic(user));
            _context.SaveChanges();

            return(true);
        }
Example #5
0
        public bool AddRatingForEpic(Domain.Models.Rating rating)
        {
            Rating r = new Rating();

            try {
                r = _context.Ratings.First(r => r.EpicId == rating.RatingEpic.ID && r.RaterId == rating.Rater.ID);
            }
            catch
            {
                var newModel = Mappers.RatingMapper.MapFull(rating);
                _context.Add(newModel);
                _context.SaveChanges();
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Adds Comment to epic
        /// </summary>
        /// <param name="comment">Domain Model Object</param>
        /// <returns>True if comment successfully added to epic in database</returns>
        public bool AddComment(Domain.Models.Comment comment)
        {
            var dbComment = new Comment
            {
                Id          = comment.ID,
                CommenterId = comment.Commenter.ID,
                EpicId      = comment.CommentEpic.ID,
                Comment1    = comment.CommentContent,
                DateCreated = (DateTime)comment.Date
            };

            _context.Comments.Add(dbComment);
            _context.SaveChanges();

            return(true);
        }
Example #7
0
        public bool AddChapter(Domain.Models.Chapter chapter)
        {
            var dbEpic = _context.Epics
                         .FirstOrDefault(e => e.Id == chapter.EpicID);

            //Epic does not exist in database return false
            if (dbEpic == null)
            {
                return(false);
            }

            var dbChapter = Mappers.ChapterMapper.MapDomainToDB(chapter);

            _context.Chapters.Add(dbChapter);
            _context.SaveChanges();

            return(true);
        }