Ejemplo n.º 1
0
        public Guid InsertTopic(TopicModel topic)
        {
            Guid id = Guid.NewGuid();

            if (topic == null)
            {
                throw new NullReferenceException("theme");
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                TOPIC _new = new TOPIC
                {
                    ID            = id,
                    ID_THEME      = topic.Theme.Id,
                    NAME          = topic.Name,
                    DESCRIPTION   = topic.Description,
                    IS_ACTIVE     = topic.IsActive,
                    IMAGE         = topic.Image,
                    CREATION_DATE = DateTime.Now,
                    UPDATE_DATE   = DateTime.Now
                };

                data.TOPIC.AddObject(_new);
                data.SaveChanges();
            }

            return(id);
        }
Ejemplo n.º 2
0
 public IList <TopicModel> GetTopicsForPoint(Guid PointId)
 {
     using (AppTourEntities data = new AppTourEntities())
     {
         return(this.GetTopicsForPoint(data, PointId).ToList());
     }
 }
Ejemplo n.º 3
0
        public void UpdateTopic(TopicModel topic)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                TOPIC current = data.TOPIC.Where(x => topic.Id == x.ID).SingleOrDefault();
                if (current != null)
                {
                    try
                    {
                        current.NAME          = topic.Name;
                        current.DESCRIPTION   = topic.Description;
                        current.IMAGE         = topic.Image;
                        current.IS_ACTIVE     = topic.IsActive;
                        current.CREATION_DATE = topic.CreationDate;
                        current.UPDATE_DATE   = DateTime.Now;

                        current.THEME = data.THEME.Where(x => x.ID == topic.Theme.Id).SingleOrDefault();

                        data.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        if (e.InnerException != null)
                        {
                            throw new Exception(e.InnerException.Message);
                        }
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public IList <TopicModel> GetTopics()
 {
     using (AppTourEntities data = new AppTourEntities())
     {
         return(this.GetTopic(data).ToList());
     }
 }
Ejemplo n.º 5
0
 public IList <TopicModel> GetActiveTopics()
 {
     using (AppTourEntities data = new AppTourEntities())
     {
         return(this.GetTopic(data).Where(f => f.IsActive).ToList());
     }
 }
Ejemplo n.º 6
0
        private IQueryable <TopicModel> GetTopic(AppTourEntities data)
        {
            var query = from c in data.TOPIC
                        orderby c.NAME
                        select new TopicModel
            {
                Id    = c.ID,
                Theme = (from t in data.THEME
                         where t.ID == c.THEME.ID
                         select new ThemeModel
                {
                    Id = t.ID,
                    Name = t.NAME,
                    Description = t.DESCRIPTION,
                    Image = t.IMAGE,
                    IsActive = t.IS_ACTIVE,
                    CreationDate = t.CREATION_DATE,
                    UpdateDate = t.UPDATE_DATE
                }).FirstOrDefault(),
                Name         = c.NAME,
                Description  = c.DESCRIPTION,
                Image        = c.IMAGE,
                IsActive     = c.IS_ACTIVE,
                CreationDate = c.CREATION_DATE,
                UpdateDate   = c.UPDATE_DATE
            };

            return(query);
        }
Ejemplo n.º 7
0
        public Guid InsertComment(CommentModel Comment)
        {
            if (Comment == null)
            {
                throw new NullReferenceException();
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                COMMENT _new = new COMMENT
                {
                    ID            = (Comment.Id == null || Comment.Id == Guid.Empty ? Guid.NewGuid() : Comment.Id),
                    EVENT         = (Comment.Event != null ? data.EVENT.SingleOrDefault(x => x.ID.Equals(Comment.Event.Id)) : null),
                    POINT         = (Comment.Point != null ? data.POINT.SingleOrDefault(x => x.ID.Equals(Comment.Point.Id)) : null),
                    IS_REPORTED   = Comment.IsReported,
                    IS_ACTIVE     = Comment.IsActive,
                    USER          = data.USER.SingleOrDefault(x => x.ID.Equals(Comment.User.Id)),
                    COMMENT1      = Comment.Comment,
                    CREATION_DATE = DateTime.Now
                };

                data.COMMENT.AddObject(_new);
                data.SaveChanges();

                return(_new.ID);
            }
        }
Ejemplo n.º 8
0
        private IQueryable <CommentModel> GetCommentsForEvent(AppTourEntities data, Guid EventId)
        {
            var query = from c in data.COMMENT
                        where c.EVENT.ID.Equals(EventId) && c.IS_ACTIVE
                        orderby c.CREATION_DATE
                        select new CommentModel
            {
                Id           = c.ID,
                Comment      = c.COMMENT1,
                CreationDate = c.CREATION_DATE,
                IsActive     = c.IS_ACTIVE,
                IsReported   = c.IS_REPORTED,
                User         = (from u in data.USER
                                where u.ID.Equals(c.USER.ID)
                                select new UserModel
                {
                    Id = u.ID,
                    RealName = u.REALNAME,
                    IsActive = u.IS_ACTIVE,
                    CreationDate = u.CREATION_DATE,
                    UpdateDate = u.UPDATE_DATE
                }).FirstOrDefault()
            };

            return(query);
        }
Ejemplo n.º 9
0
        public IList <CommentModel> GetCommentsForEvent(Guid EventId)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                IList <CommentModel> comments = this.GetCommentsForEvent(data, EventId).ToList();

                return(comments);
            }
        }
Ejemplo n.º 10
0
        public PointModel GetPointForSearch(Guid Id)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                PointModel point = this.GetPoints(data).SingleOrDefault(x => x.Id == Id);
                point.Topics = new TopicRepository().GetTopicsForPoint(point.Id);

                return(point);
            }
        }
Ejemplo n.º 11
0
        public IList <ClassificationModel> GetClassificationForPoint(PointModel Point)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                IList <ClassificationModel> list = GetClassificationForPoint(data, Point.Id).ToList();
                list.ToList().ForEach(x => x.Point = Point);

                return(list);
            }
        }
Ejemplo n.º 12
0
        public UserModel GetActiveUser(Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentNullException();
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                return(this.GetUsers(data).Where(x => x.Id == id && x.IsActive == true).First());
            }
        }
Ejemplo n.º 13
0
        public UserModel GetUser(Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentNullException();
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                return(this.GetUsers(data).SingleOrDefault(x => x.Id == id));
            }
        }
Ejemplo n.º 14
0
        public LanguageModel GetLanguage(Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentNullException("id");
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                return(this.GetLanguages(data).Where(x => x.Id == id).First());
            }
        }
Ejemplo n.º 15
0
        public CountryModel GetCountry(Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentNullException();
            }

            using (AppTourEntities data = new AppTourEntities())
            {
                return(this.GetCountries(data).Where(x => x.Id == id).First());
            }
        }
Ejemplo n.º 16
0
        public IList <TranslationModel> GetTranslations(string TableName, Guid ForeignId, Guid?LanguageId)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                if (LanguageId != null)
                {
                    return(this.GetTranslations(data, TableName, ForeignId, (Guid)LanguageId).ToList());
                }

                return(this.GetTranslations(data, TableName, ForeignId).ToList());
            }
        }
Ejemplo n.º 17
0
        private IQueryable <PictureModel> GetPicturesFromPoint(AppTourEntities data, Guid PointId)
        {
            var query = (from c in data.PICTURE
                         where c.POINT.ID.Equals(PointId)
                         select new PictureModel
            {
                Id = c.ID,
                Picture_URL = c.PIC_URL
            });

            return(query);
        }
Ejemplo n.º 18
0
        public Guid InsertSearchProfile(SearchProfileModel searchProfile)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                try
                {
                    SEARCH_PROFILE novo = new SEARCH_PROFILE
                    {
                        ID   = searchProfile.Id == null || searchProfile.Id == Guid.Empty ? Guid.NewGuid() : searchProfile.Id,
                        NAME = searchProfile.Name,
                        POINTS_RANGE_DISTANCE = searchProfile.PointsRangeDistance,
                        SEARCH_CRITERIA       = searchProfile.SearchCriteria,
                        EVENTS_SEARCH_DAYS    = searchProfile.EventsSearchDays,
                        CREATION_DATE         = DateTime.Now,
                        UPDATE_DATE           = DateTime.Now,
                        IS_ACTIVE             = searchProfile.IsActive,
                        USER = data.USER.Single(x => x.ID == searchProfile.Utilizador.Id)
                    };

                    if (searchProfile.SearchProfileTopics != null && searchProfile.SearchProfileTopics.Count() > 0)
                    {
                        // Adicionar Atributos
                        searchProfile.SearchProfileTopics.ToList().ForEach(x => novo.SEARCH_PROFILE_TOPIC.Add(new SEARCH_PROFILE_TOPIC
                        {
                            ID             = Guid.NewGuid(),
                            TOPIC          = data.TOPIC.SingleOrDefault(y => y.ID == x.Id),
                            SEARCH_PROFILE = novo
                        }));
                    }

                    // Guardar tudo

                    data.SEARCH_PROFILE.AddObject(novo);
                    data.SaveChanges();

                    return(novo.ID);
                }
                catch (UpdateException upd)
                {
                    throw new UpdateException(upd.InnerException.Message);
                }
                catch (Exception e)
                {
                    if (e.InnerException != null)
                    {
                        throw new ApplicationException(e.InnerException.Message);
                    }

                    throw;
                }
            }
        }
Ejemplo n.º 19
0
 public IList <PointModel> GetPoints()
 {
     using (AppTourEntities data = new AppTourEntities())
     {
         var points = this.GetPoints(data).ToList();
         points.ToList().ForEach(x =>
         {
             x.Topics     = new TopicRepository().GetTopicsForPoint(x.Id);
             x.Attributes = new PointAttributeRepository().GetAttributeForPoints(x.Id);
         });
         return(points);
     }
 }
Ejemplo n.º 20
0
        private IQueryable <LanguageModel> GetLanguages(AppTourEntities data)
        {
            var query = from c in data.LANGUAGE
                        orderby c.NAME
                        select new LanguageModel
            {
                Id       = c.ID,
                Name     = c.NAME,
                ISO2     = c.ISO2,
                IsActive = c.IS_ACTIVE
            };

            return(query);
        }
Ejemplo n.º 21
0
        private IQueryable <UserModel> GetUsers(AppTourEntities data)
        {
            var query = from c in data.USER
                        select new UserModel
            {
                Id           = c.ID,
                RealName     = c.REALNAME,
                IsActive     = c.IS_ACTIVE,
                CreationDate = c.CREATION_DATE,
                UpdateDate   = c.UPDATE_DATE
            };

            return(query);
        }
Ejemplo n.º 22
0
        public IList <SearchProfileModel> GetSearchProfiles()
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                IQueryable <SearchProfileModel> profileList = this.GetSearchProfiles(data);

                profileList.ToList().ForEach(x =>
                {
                    x.SearchProfileTopics = new TopicRepository().GetTopicsForSearchProfile(x.Id);
                });

                return(profileList.ToList());
            }
        }
Ejemplo n.º 23
0
        public IList <SearchProfileModel> GetSearchProfiles(Guid UserId)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                IList <SearchProfileModel> profileList = this.GetSearchProfiles(data, UserId).ToList();

                profileList.AsParallel().ForAll(x =>
                {
                    x.SearchProfileTopics = new TopicRepository().GetTopicsForSearchProfile(x.Id);
                });

                return(profileList.ToList());
            }
        }
Ejemplo n.º 24
0
        public IList <PointModel> GetActivePoints(TopicModel Topic)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                var points = this.GetActivePoints(data, Topic).ToList();

                Parallel.ForEach(points, x =>
                {
                    x.Topics     = new TopicRepository().GetTopicsForPoint(x.Id);
                    x.Attributes = new PointAttributeRepository().GetAttributeForPoints(x.Id);
                });

                return(points.ToList());
            }
        }
Ejemplo n.º 25
0
        public SearchProfileModel GetSearchProfile(Guid SearchProfileID)
        {
            using (AppTourEntities data = new AppTourEntities())
            {
                SearchProfileModel profile = this.GetSearchProfiles(data).SingleOrDefault(x => x.Id == SearchProfileID);
                if (profile == null)
                {
                    return(null);
                }

                profile.SearchProfileTopics = new TopicRepository().GetTopicsForSearchProfile(SearchProfileID);

                return(profile);
            }
        }
Ejemplo n.º 26
0
        private IQueryable <EnterpriseModel> GetEnterprises(AppTourEntities data)
        {
            var query = from c in data.ENTERPRISE
                        orderby c.NAME
                        select new EnterpriseModel
            {
                Id           = c.ID,
                Name         = c.NAME,
                Description  = c.DESCRIPTION,
                CreationDate = c.CREATION_DATE,
                UpdateDate   = c.UPDATE_DATE
            };

            return(query);
        }
Ejemplo n.º 27
0
        private IQueryable <CountryModel> GetCountries(AppTourEntities data)
        {
            var query = from c in data.COUNTRY
                        orderby c.NAME
                        select new CountryModel
            {
                Id          = c.ID,
                Name        = c.NAME,
                CountryCode = c.COUNTRY_CODE,
                CountryName = c.COUNTRY_NAME,
                ISO         = c.ISO,
                ISO3        = c.ISO3
            };

            return(query);
        }
Ejemplo n.º 28
0
        private CountryModel GetCountries(AppTourEntities data, string ISO)
        {
            var query = from c in data.COUNTRY
                        where c.ISO == ISO
                        select new CountryModel
            {
                Id          = c.ID,
                Name        = c.NAME,
                CountryCode = c.COUNTRY_CODE,
                CountryName = c.COUNTRY_NAME,
                ISO         = c.ISO,
                ISO3        = c.ISO3
            };

            return(query.SingleOrDefault());
        }
Ejemplo n.º 29
0
        private IQueryable <ThemeModel> GetTheme(AppTourEntities data)
        {
            var query = from c in data.THEME
                        orderby c.NAME
                        select new ThemeModel
            {
                Id           = c.ID,
                Name         = c.NAME,
                Description  = c.DESCRIPTION,
                Image        = c.IMAGE,
                IsActive     = c.IS_ACTIVE,
                CreationDate = c.CREATION_DATE,
                UpdateDate   = c.UPDATE_DATE
            };

            return(query);
        }
Ejemplo n.º 30
0
        private IQueryable <TopicModel> GetTopicsForPoint(AppTourEntities data, Guid PointModelId)
        {
            var query = from t in data.TOPIC
                        join p in data.POINT_TOPIC on t.ID equals p.ID_TOPIC
                        where p.ID_POINT.Equals(PointModelId)
                        select new TopicModel
            {
                Id           = t.ID,
                Name         = t.NAME,
                Description  = t.DESCRIPTION,
                IsActive     = t.IS_ACTIVE,
                CreationDate = t.CREATION_DATE,
                UpdateDate   = t.UPDATE_DATE
            };

            return(query);
        }