Exemplo n.º 1
0
        public IEnumerable <IFoodChoice> FetchFoodChoicesForGuests(IEnumerable <IWeddingGuest> guests)
        {
            var db       = new TooksCmsDAL();
            var guestIds = guests.Select(g => g.GuestId).ToList();

            return(db.FoodChoices.Where(_fc => guestIds.Contains(_fc.GuestId)));
        }
Exemplo n.º 2
0
        public void DeleteRoute(int id)
        {
            var db = new TooksCmsDAL();

            db.StaticRoutes.Remove(db.StaticRoutes.Single(r => r.Id == id));
            db.SaveChanges();
        }
Exemplo n.º 3
0
        private IArticleImage _insert(IArticleImage data, TooksCmsDAL db)
        {
            var i = ArticleImage.CreateArticleImage(data);

            db.ArticleImages.Add(i);
            return(i);
        }
Exemplo n.º 4
0
        public IEnumerable <IBulletin> FetchList()
        {
            var db = new TooksCmsDAL();

            return(db.Bulletins.OrderByDescending(b_ => b_.Date)
                   .ThenBy(b_ => b_.BulletinId));
        }
Exemplo n.º 5
0
        public void DeleteComment(int commentId)
        {
            var db = new TooksCmsDAL();

            db.ArticleComments.Remove(db.ArticleComments.Single(c => c.ArticleCommentId == commentId));
            db.SaveChanges();
        }
Exemplo n.º 6
0
        public IEnumerable <IRankedTag> FetchRankedTags(int count)
        {
            var db = new TooksCmsDAL();

            return(db.Tags.OrderByDescending(t => (t.Articles.Count + t.Galleries.Count)).Take(count).Select(t => new RankedTag {
                Tag = t, Rank = (t.Articles.Count + t.Galleries.Count)
            }));
        }
Exemplo n.º 7
0
        private void CreateRatingLink(TooksCmsDAL db, int ratingId, int articleTypeId, int categoryid, int ordinal)
        {
            var link = new Rating2ArticleType2Category {
                RatingId = ratingId, ArticleTypeId = articleTypeId, CategoryId = categoryid, Ordinal = ordinal
            };

            db.Rating2ArticleType2Category.Add(link);
        }
Exemplo n.º 8
0
        public IPageVisit InsertPageVisit(IPageVisit data)
        {
            var db = new TooksCmsDAL();
            var s  = PageVisit.CreatePageVisit(data);

            db.PageVisits.Add(s);
            db.SaveChanges();
            return(s);
        }
Exemplo n.º 9
0
        public ICategory InsertCategory(ICategory data)
        {
            var db = new TooksCmsDAL();
            var c  = Category.CreateCategory(data);

            db.Categories.Add(c);
            db.SaveChanges();
            return(c);
        }
Exemplo n.º 10
0
        public IBulletin InsertContent(IBulletin data)
        {
            var db = new TooksCmsDAL();
            var b  = db.Bulletins.SingleOrDefault(b_ => b_.BulletinId == data.BulletinId);

            b.BulletinContents.Add(BulletinContent.CreateBulletinContent(data));
            db.SaveChanges();
            return(b);
        }
Exemplo n.º 11
0
        public IEnumerable <IBulletin> FetchList(int count, int skip)
        {
            var db = new TooksCmsDAL();

            return(db.Bulletins.OrderByDescending(b_ => b_.Date)
                   .ThenBy(b_ => b_.BulletinId)
                   .Skip(skip)
                   .Take(count));
        }
Exemplo n.º 12
0
        public IEnumerable <IBulletin> FetchList(int count, DateTime from)
        {
            var db = new TooksCmsDAL();

            return(db.Bulletins.Where(b_ => b_.Date >= from)
                   .OrderByDescending(b_ => b_.Date)
                   .ThenBy(b_ => b_.BulletinId)
                   .Take(count));
        }
Exemplo n.º 13
0
        public void InsertEvent(IEventLog data)
        {
            var db = new TooksCmsDAL();

            var e = EventLog.CreateEventLog(data);

            db.EventLogs.Add(e);

            db.SaveChanges();
        }
Exemplo n.º 14
0
        public IEnumerable <IContactForm> FetchContactFormList(int count, int skip = 0)
        {
            var db = new TooksCmsDAL();

            if (count > 0)
            {
                return(db.ContactForms.OrderBy(cf => cf.Date).Skip(skip).Take(count));
            }
            return(db.ContactForms.OrderBy(cf => cf.Date).Skip(0));
        }
Exemplo n.º 15
0
        public IArticle InsertContent(IArticle data)
        {
            var db = new TooksCmsDAL();
            var a  = db.Articles.SingleOrDefault(a_ => a_.ArticleId == data.ArticleId);

            a.UpdateContent(data);

            db.SaveChanges();
            return(a);
        }
Exemplo n.º 16
0
        public IFoodChoice AddFoodChoice(IFoodChoice choice)
        {
            var db = new TooksCmsDAL();

            var f = db.FoodChoices.Add(FoodChoice.CreateFoodChoice(choice));

            db.SaveChanges();

            return(f);
        }
Exemplo n.º 17
0
        public IBulletin Fetch(int id)
        {
            var db = new TooksCmsDAL();

            if (!_exists(id, db))
            {
                throw new DataNotFoundException("Bulletin does not exits", "id");
            }
            return(db.Bulletins.SingleOrDefault(b_ => b_.BulletinId == id));
        }
Exemplo n.º 18
0
        public IWeddingGuest AddGuest(IWeddingGuest guest)
        {
            var db = new TooksCmsDAL();

            var g = db.Guest1.Add(Guest1.CreatGuest(guest));

            db.SaveChanges();

            return(g);
        }
Exemplo n.º 19
0
        public void RemoveGadgetLink(IGadgetInfo data)
        {
            var db = new TooksCmsDAL();
            var gl = db.Gadget2Role2AreaType.Single(gl_ => gl_.AreaType.AreaType1 == data.AreaType &&
                                                    gl_.GadgetId == data.GadgetId &&
                                                    gl_.Role.RoleName == data.RoleName);

            db.Gadget2Role2AreaType.Remove(gl);
            db.SaveChanges();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Inserts a new user into the DAL.
        /// </summary>
        /// <param name="data">DTO to create from</param>
        /// <returns>An User DAL object</returns>
        /// <exception cref="System.ArgumentException">Errors in data will result in an exception being thrown</exception>
        public IUser InsertUser(IUser data)
        {
            var db = new TooksCmsDAL();
            var u  = User.CreateUser(data);

            db.Users.Add(u);

            db.SaveChanges();

            return(u);
        }
Exemplo n.º 21
0
        public IArticleComment FetchComment(int id)
        {
            var db = new TooksCmsDAL();

            if (!db.ArticleComments.Any(ac_ => ac_.ArticleCommentId == id))
            {
                throw new DataNotFoundException("Article does not exits", "id");
            }

            return(db.ArticleComments.SingleOrDefault(a_ => a_.ArticleCommentId == id));
        }
Exemplo n.º 22
0
        public IContactForm FetchContactForm(int id)
        {
            var db = new TooksCmsDAL();

            if (!db.ContactForms.Any(cf => cf.ContactFormId == id))
            {
                throw new DataNotFoundException("ContactForm not found in database with id: " + id.ToString());
            }

            return(db.ContactForms.Single(cf => cf.ContactFormId == id));
        }
Exemplo n.º 23
0
        public IArticle Fetch(int id)
        {
            var db = new TooksCmsDAL();

            if (!_exists(id, db))
            {
                throw new DataNotFoundException("Article does not exits", "id");
            }

            return(db.Articles.SingleOrDefault(a_ => a_.ArticleId == id));
        }
Exemplo n.º 24
0
        public IArticleType FetchType(string name)
        {
            var db = new TooksCmsDAL();

            if (!_typeExists(name, db))
            {
                throw new DataNotFoundException("ArticleType does not exits", "name");
            }

            return(db.ArticleTypes.FirstOrDefault(at_ => at_.Name.ToLower() == name.ToLower()));
        }
Exemplo n.º 25
0
        public IArticleType FetchType(int id)
        {
            var db = new TooksCmsDAL();

            if (!_typeExists(id, db))
            {
                throw new DataNotFoundException("ArticleType does not exits", "id");
            }

            return(db.ArticleTypes.FirstOrDefault(at_ => at_.ArticleTypeId == id));
        }
Exemplo n.º 26
0
        /// <summary>
        /// Fetch a role from the DAL.
        /// </summary>
        /// <param name="id">ID of the role</param>
        /// <returns>A Role DTO object</returns>
        /// <exception cref="TooksCms.Core.Exceptions.DataNotFoundException">Role does not exist</exception>
        public IRole FetchRole(int id)
        {
            var db = new TooksCmsDAL();

            if (!_roleExists(id, db))
            {
                throw new DataNotFoundException("Role does not exist", "id");
            }

            return(db.Roles.FirstOrDefault(r_ => r_.RoleId == id));
        }
Exemplo n.º 27
0
        public IGallery FetchGallery(int galleryId)
        {
            var db = new TooksCmsDAL();

            if (!CheckGalleryExists(db, galleryId))
            {
                throw new DataNotFoundException("Database does not contain Gallery with id:" + galleryId.ToString());
            }

            return(db.Galleries.Single(g_ => g_.GalleryId == galleryId));
        }
Exemplo n.º 28
0
        public IRating InsertRating(IRating data)
        {
            var db = new TooksCmsDAL();

            var r = Rating.CreateRating(data);

            db.Ratings.Add(r);
            db.SaveChanges();

            return(r);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Fetch a role from the DAL.
        /// </summary>
        /// <param name="name">Name of the role</param>
        /// <returns>A Role DTO object</returns>
        /// <exception cref="TooksCms.Core.Exceptions.DataNotFoundException">Role does not exist</exception>
        public IRole FetchRole(string name)
        {
            var db = new TooksCmsDAL();

            if (!_roleExists(name, db))
            {
                throw new DataNotFoundException("Role does not exist", "id");
            }

            return(db.Roles.FirstOrDefault(r_ => r_.RoleName == name));
        }
Exemplo n.º 30
0
        public IRating UpdateRating(IRating data)
        {
            var db = new TooksCmsDAL();

            var r = db.Ratings.First(r_ => r_.RatingId == data.RatingId);

            r.Update(data);
            db.SaveChanges();

            return(r);
        }