Exemplo n.º 1
0
 public static void AddComment(Comment comment)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     CommentEntry comm = new CommentEntry();
     Converter.CopyFields(comment, comm);
     comDS.AddComment(comm);
 }
        public DatasetCommentsDataSource()
        {
            IEnumerable <EntitySet> entitySets = new List <EntitySet>();

            foreach (Container container in ContainerAliases)
            {
                var sets = EntitySetRepository.GetEntitySets(container.Alias, null) as List <EntitySet>;
                if (sets != null)
                {
                    entitySets = entitySets.Union(sets);
                }
            }

            var cds = new CommentsDataSource();
            IEnumerable <CommentEntry> comments = cds.SelectAll().Where(t => t.ParentType == ParentType.Dataset.ToString());

            _list = (from es in entitySets
                     join c in comments on es.EntitySetName equals c.DatasetId
                     select new DatasetComment(es.EntityId, es.Name, es.Description, es.CategoryValue, es.ContainerAlias, es.LastUpdateDate, es.EntitySetName, c.Subject, c.Username, c.Email, c.PostedOn));

            _list = _list.OrderBy(c => c.CommentDate)
                    .OrderBy(c => c.DatasetName)
                    .OrderBy(c => c.DatasetCategoryValue)
                    .OrderBy(c => c.DatasetContainerAlias);
        }
Exemplo n.º 3
0
        static public void AddComment(Comment comment)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            CommentEntry       comm  = new CommentEntry();

            Converter.CopyFields(comment, comm);
            comDS.AddComment(comm);
        }
Exemplo n.º 4
0
        static public void Update(Comment comment)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            CommentEntry       comm  = comDS.GetById(comment.RowKey);

            Converter.CopyFields(comment, comm);
            comDS.Update(comm);
        }
Exemplo n.º 5
0
        public static Comment GetComment(string id)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            CommentEntry comm = comDS.GetById(id);

            return CreateCommentEnumerator(new List<CommentEntry>() { comm }).FirstOrDefault();
        }
Exemplo n.º 6
0
        public static IEnumerable<Comment> GetDatasetComments(string datasetId, string parentType, string container)
        {
            var commentDS = new CommentsDataSource();

            var comments = from g in commentDS.SelectAll()
                          where g.DatasetId == datasetId && g.ParentType == parentType && container == g.PartitionKey
                          select g;

            return CreateCommentEnumerator(comments);
        }
Exemplo n.º 7
0
        public static IEnumerable<Comment> GetByParentAndUser(string parentId, string container, string parentType, string user)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            var comments = from g in comDS.SelectAll()
                          where g.DatasetId == parentId && g.PartitionKey == container && g.ParentType == parentType && g.Email == user
                          select g;

            return CreateCommentEnumerator(comments);
        }
Exemplo n.º 8
0
        static public IEnumerable <Comment> GetByParentAndUser(string parentId, string container, string parentType, string user)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            var comments = from g in comDS.SelectAll()
                           where g.DatasetId == parentId && g.PartitionKey == container && g.ParentType == parentType && g.Email == user
                           select g;

            return(CreateCommentEnumerator(comments));
        }
Exemplo n.º 9
0
        static public IEnumerable <Comment> GetDatasetComments(string datasetId, string parentType, string container)
        {
            var commentDS = new CommentsDataSource();

            var comments = from g in commentDS.SelectAll()
                           where g.DatasetId == datasetId && g.ParentType == parentType && container == g.PartitionKey
                           select g;

            return(CreateCommentEnumerator(comments));
        }
Exemplo n.º 10
0
        static public Comment GetComment(string id)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            CommentEntry comm = comDS.GetById(id);

            return(CreateCommentEnumerator(new List <CommentEntry>()
            {
                comm
            }).FirstOrDefault());
        }
Exemplo n.º 11
0
        static public IEnumerable <String> GetSubscribers(string objectId, string container, string parentType, string exclude)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            var results = from com in comDS.SelectAll()
                          where com.Notify == true &&
                          com.Email != "" &&
                          com.DatasetId == objectId &&
                          com.PartitionKey == container &&
                          com.ParentType == parentType &&
                          com.RowKey != exclude
                          select com;

            return(results.AsEnumerable().Select(c => c.Email).Distinct());
        }
Exemplo n.º 12
0
        public static IEnumerable<Comment> GetComments(DateTime? fromDate, DateTime? toDate)
        {
            // We should use values SqlDateTime.MinValue otherwies exception during query execution
            //January 1, 1753.
            if (!fromDate.HasValue)
                fromDate = SqlDateTime.MinValue.Value;

            //December 31, 9999.
            if (!toDate.HasValue)
                toDate = DateTime.Now;

            var commentDS = new CommentsDataSource();

            var comments = (from comm in commentDS.SelectAllWithHidden()
                            where comm.PostedOn >= fromDate && comm.PostedOn <= toDate
                            select comm).AsEnumerable();

            return CreateCommentEnumerator(comments);
        }
Exemplo n.º 13
0
        public ActionResult DeleteRequest(string rowKey)
        {
            Request re = RequestRepository.GetRequest(rowKey);

            if (re == null)
            {
                throw new ApplicationException("Requested request does not exist.");
            }

            var commentsDataSource = new CommentsDataSource();

            commentsDataSource.UpdateStatusByParent(rowKey, "Request", "Hidden");

            re.Status = "Hidden";
            RequestRepository.UpdateRequest(re);

            //string result = string.Format("<h2 style='color:red'>Request: \"{0}\" is deleted</h2>", re.Subject);
            //return Json(result);
            return(Json(new StatusInfo {
                Status = re.Status, Show = true
            }));
        }
Exemplo n.º 14
0
        static public IEnumerable <Comment> GetComments(DateTime?fromDate, DateTime?toDate)
        {
            // We should use values SqlDateTime.MinValue otherwies exception during query execution
            //January 1, 1753.
            if (!fromDate.HasValue)
            {
                fromDate = SqlDateTime.MinValue.Value;
            }

            //December 31, 9999.
            if (!toDate.HasValue)
            {
                toDate = DateTime.Now;
            }

            var commentDS = new CommentsDataSource();

            var comments = (from comm in commentDS.SelectAllWithHidden()
                            where comm.PostedOn >= fromDate && comm.PostedOn <= toDate
                            select comm).AsEnumerable();

            return(CreateCommentEnumerator(comments));
        }
Exemplo n.º 15
0
 public static void DeleteComment(string id)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     comDS.DeleteComment(id);
 }
Exemplo n.º 16
0
 public static void DeleteByParent(string parentId, string container)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     comDS.DeleteByParent(parentId, container);
 }
Exemplo n.º 17
0
        public static IEnumerable<String> GetSubscribers(string objectId, string container, string parentType, string exclude)
        {
            CommentsDataSource comDS = new CommentsDataSource();
            var results = from com in comDS.SelectAll()
                          where com.Notify == true
                          && com.Email != ""
                          && com.DatasetId == objectId
                          && com.PartitionKey == container
                          && com.ParentType == parentType
                          && com.RowKey != exclude
                          select com;

            return results.AsEnumerable().Select(c => c.Email).Distinct();
        }
Exemplo n.º 18
0
 public static void Update(Comment comment)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     CommentEntry comm = comDS.GetById(comment.RowKey);
     Converter.CopyFields(comment, comm);
     comDS.Update(comm);
 }
Exemplo n.º 19
0
        static public void DeleteByParent(string parentId, string container)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            comDS.DeleteByParent(parentId, container);
        }
Exemplo n.º 20
0
        static public void DeleteComment(string id)
        {
            CommentsDataSource comDS = new CommentsDataSource();

            comDS.DeleteComment(id);
        }
Exemplo n.º 21
0
 private void LoadComments()
 {
     CommentsDataSource ds = new CommentsDataSource();
     Comments = new List<Comment>(CommentRepository.GetDatasetComments(DatasetId, ParentType.ToString(), Container));
 }