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); }
public IList <TopicModel> GetTopicsForPoint(Guid PointId) { using (AppTourEntities data = new AppTourEntities()) { return(this.GetTopicsForPoint(data, PointId).ToList()); } }
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; } } } }
public IList <TopicModel> GetTopics() { using (AppTourEntities data = new AppTourEntities()) { return(this.GetTopic(data).ToList()); } }
public IList <TopicModel> GetActiveTopics() { using (AppTourEntities data = new AppTourEntities()) { return(this.GetTopic(data).Where(f => f.IsActive).ToList()); } }
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); }
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); } }
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); }
public IList <CommentModel> GetCommentsForEvent(Guid EventId) { using (AppTourEntities data = new AppTourEntities()) { IList <CommentModel> comments = this.GetCommentsForEvent(data, EventId).ToList(); return(comments); } }
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); } }
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); } }
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()); } }
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)); } }
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()); } }
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()); } }
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()); } }
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); }
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; } } }
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); } }
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); }
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); }
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()); } }
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()); } }
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()); } }
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); } }
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); }
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); }
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()); }
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); }
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); }