Example #1
0
        public string UpdateBlogComment(string commentid, string content)
        {
            Guid?id = null;

            if (!String.IsNullOrEmpty(commentid))
            {
                id = new Guid(commentid);
            }

            var comment = BlogEngine.GetCommentById(id.Value);

            if (comment == null)
            {
                throw new Exception("Comment not found");
            }

            CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment);

            comment.Content = content;

            var post = BlogEngine.GetPostById(comment.PostId);

            BlogEngine.UpdateComment(comment, post);

            return(HtmlUtility.GetFull(content));
        }
Example #2
0
        public EventWrapperFull CreateEvent(string content, string title, FeedType type)
        {
            CommunitySecurity.DemandPermissions(NewsConst.Action_Add);

            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException("Can't create feed with empty title", "title");
            }

            if (type != FeedType.News && type != FeedType.Order && type != FeedType.Advert && type != FeedType.Poll)
            {
                throw new ArgumentOutOfRangeException(string.Format("Unknown feed type: {0}.", type));
            }

            var feed = new Feed
            {
                Caption  = title,
                Text     = content,
                Creator  = SecurityContext.CurrentAccount.ID.ToString(),
                Date     = DateTime.UtcNow,
                FeedType = type
            };

            FeedStorage.SaveFeed(feed, false, type);

            return(new EventWrapperFull(feed));
        }
Example #3
0
        public string RemoveComment(string commentID, string pid)
        {
            Guid?id = null;

            try
            {
                if (!String.IsNullOrEmpty(commentID))
                {
                    id = new Guid(commentID);
                }
            }
            catch
            {
                return(commentID);
            }

            var engine = GetEngine();

            var comment = engine.GetCommentById(id.Value);

            if (comment == null)
            {
                throw new ApplicationException("Comment not found");
            }

            CommunitySecurity.DemandPermissions(comment, Constants.Action_EditRemoveComment);

            comment.Inactive = true;

            var post = engine.GetPostById(comment.PostId);

            engine.RemoveComment(comment, post);

            return(commentID);
        }
Example #4
0
        public AjaxResponse Remove(string id)
        {
            try
            {
                var resp = new AjaxResponse {
                    rs1 = "0"
                };
                if (!string.IsNullOrEmpty(id))
                {
                    var feedId  = Convert.ToInt64(id);
                    var storage = FeedStorageFactory.Create();

                    var feed = storage.GetFeed(feedId);
                    CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

                    foreach (var comment in storage.GetFeedComments(feedId))
                    {
                        CommonControlsConfigurer.FCKUploadsRemoveForItem("news_comments", comment.Id.ToString());
                    }

                    storage.RemoveFeed(feed);
                    CommonControlsConfigurer.FCKUploadsRemoveForItem("news", id);

                    resp.rs1 = id;
                    resp.rs2 = NewsResource.FeedDeleted;
                }
                return(resp);
            }
            catch (Exception err)
            {
                return(new AjaxResponse {
                    rs1 = "1", rs2 = err.Message,
                });
            }
        }
Example #5
0
        public AjaxResponse AddComment(string parentCommentId, string pageName, string text, string pid)
        {
            CommunitySecurity.DemandPermissions(Common.Constants.Action_AddComment);

            var resp = new AjaxResponse();

            resp.rs1 = parentCommentId;

            var parentIdGuid = String.IsNullOrEmpty(parentCommentId) ? Guid.Empty : new Guid(parentCommentId);
            var newComment   = Wiki.CreateComment(new Comment {
                Body = text, PageName = pageName, ParentId = parentIdGuid
            });

            var info = GetCommentInfo(newComment);

            var defComment = new CommentsList();

            ConfigureComments(defComment, pageName);

            var visibleCommentsCount = Wiki.GetComments(pageName).Count;

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(
                defComment,
                info,
                string.IsNullOrEmpty(parentCommentId),
                visibleCommentsCount % 2 == 1);

            return(resp);
        }
Example #6
0
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(WikiPage) || IsFile)
                {
                    return;
                }
                var pageName = PageNameUtil.Decode(WikiPage);

                var page = Wiki.GetPage(pageName);
                CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage);

                foreach (var cat in Wiki.GetCategoriesRemovedWithPage(pageName))
                {
                    WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.AddPageToCat, cat.CategoryName);
                }

                Wiki.RemoveCategories(pageName);

                WikiNotifySource.Instance.GetSubscriptionProvider().UnSubscribe(Common.Constants.EditPage, pageName);

                foreach (var comment in Wiki.GetComments(pageName))
                {
                    CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString());
                }
                Wiki.RemovePage(pageName);

                Response.RedirectLC("Default.aspx", this);
            }
            catch (Exception err)
            {
                WikiMaster.PrintInfoMessage(err.Message, InfoType.Alert);
            }
        }
Example #7
0
        public AjaxResponse AddComment(string parrentCommentID, string photoID, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = parrentCommentID
            };

            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddComment);

            var storage = StorageFactory.GetStorage();

            image = storage.GetAlbumItem(Convert.ToInt64(photoID));

            var newComment = new Comment(image.Id)
            {
                Text      = text,
                Timestamp = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                UserID    = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(parrentCommentID))
            {
                newComment.ParentId = Convert.ToInt64(parrentCommentID);
            }

            var count = storage.SaveComment(image, newComment);

            storage.ReadAlbumItem(newComment.ItemID, SecurityContext.CurrentAccount.ID.ToString());

            var odd = count % 2 == 1;

            var comment = newComment;

            var info = new CommentInfo
            {
                CommentID             = comment.Id.ToString(),
                UserID                = new Guid(comment.UserID),
                TimeStampStr          = comment.Timestamp.Ago(),
                IsRead                = true,
                Inactive              = comment.Inactive,
                CommentBody           = comment.Text,
                UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                UserAvatar            = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                UserPost              = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                IsEditPermissions     = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
            };

            //postParser.Parse(comment.Text);

            var defComment = new CommentsList();

            ConfigureCommentsList(defComment, image);

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, newComment.ParentId == 0, odd);


            return(resp);
        }
Example #8
0
        public string LoadCommentText(string commentID, string pid)
        {
            CommunitySecurity.DemandPermissions(PhotoConst.Action_EditRemoveComment);

            var storage = StorageFactory.GetStorage();
            var comment = storage.GetComment(Convert.ToInt64(commentID));

            return(comment.Text);
        }
Example #9
0
        public AjaxResponse AddComment(string parrentCommentID, string blogID, string text, string pid)
        {
            Guid postId;
            Guid?parentId = null;

            try
            {
                postId = new Guid(blogID);

                if (!String.IsNullOrEmpty(parrentCommentID))
                {
                    parentId = new Guid(parrentCommentID);
                }
            }
            catch
            {
                return(new AjaxResponse());
            }

            var engine = GetEngine();

            var resp = new AjaxResponse {
                rs1 = parrentCommentID
            };

            var post = engine.GetPostById(postId);

            if (post == null)
            {
                return(new AjaxResponse {
                    rs10 = "postDeleted", rs11 = Constants.DefaultPageUrl
                });
            }

            CommunitySecurity.DemandPermissions(post, Constants.Action_AddComment);

            var newComment = new Comment
            {
                PostId   = postId,
                Content  = HtmlUtility.GetFull(text),
                Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                UserID   = SecurityContext.CurrentAccount.ID
            };

            if (parentId.HasValue)
            {
                newComment.ParentId = parentId.Value;
            }

            engine.SaveComment(newComment, post);

            //mark post as seen for the current user
            engine.SavePostReview(post, SecurityContext.CurrentAccount.ID);
            resp.rs2 = GetHTMLComment(newComment, false);

            return(resp);
        }
Example #10
0
        public void SaveComment(Comment comment, Post post)
        {
            CommunitySecurity.DemandPermissions(post, ASC.Blogs.Core.Constants.Action_AddComment);
            SaveComment(comment);

            var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(comment.UserID.ToString(), ""));

            try
            {
                NotifyClient.BeginSingleRecipientEvent("asc_blog_c");
                NotifyClient.AddInterceptor(initiatorInterceptor);

                List <ITagValue> tags = new List <ITagValue>
                {
                    new TagValue(ASC.Blogs.Core.Constants.TagPostSubject, post.Title),
                    new TagValue(ASC.Blogs.Core.Constants.TagPostPreview, post.GetPreviewText(500)),
                    new TagValue(ASC.Blogs.Core.Constants.TagUserName, DisplayUserSettings.GetFullUserName(comment.UserID)),
                    new TagValue(ASC.Blogs.Core.Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(comment.UserID, CommonLinkUtility.GetProductID()))),
                    new TagValue(ASC.Blogs.Core.Constants.TagDate, string.Format("{0:d} {0:t}", comment.Datetime)),
                    new TagValue(ASC.Blogs.Core.Constants.TagCommentBody, comment.Content),

                    new TagValue(ASC.Blogs.Core.Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(ASC.Blogs.Core.Constants.ViewBlogPageUrl + "?blogID=" + post.ID.ToString())),
                    new TagValue(ASC.Blogs.Core.Constants.TagCommentURL, CommonLinkUtility.GetFullAbsolutePath(ASC.Blogs.Core.Constants.ViewBlogPageUrl + "?blogID=" + post.ID.ToString() + "#" + comment.ID.ToString())),
                    GetReplyToTag(comment.ID, post)
                };

                NotifyClient.SendNoticeAsync(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    null,
                    tags.ToArray());

                NotifyClient.EndSingleRecipientEvent("asc_blog_c");
            }
            finally
            {
                NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
            }

            BlogUserActivityPublisher.AddComment(comment, post);

            ASC.Notify.Model.ISubscriptionProvider subscriptionProvider = NotifySource.GetSubscriptionProvider();

            if (!subscriptionProvider.IsUnsubscribe((IDirectRecipient)NotifySource.GetRecipientsProvider().
                                                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), ASC.Blogs.Core.Constants.NewComment, post.ID.ToString()))
            {
                subscriptionProvider.Subscribe(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    NotifySource.GetRecipientsProvider().
                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString())
                    );
            }
        }
Example #11
0
        /// <summary>
        /// Updates comment by setting inactive flag to 1
        /// </summary>
        /// <param name="id">comment id</param>
        public void DeleteComment(Guid id)
        {
            var comment = GetComment(id);

            CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(comment), ASC.Web.Community.Wiki.Common.Constants.Action_EditRemoveComment);

            comment.Inactive = true;
            comment.Date     = TenantUtil.DateTimeNow();
            comment.UserId   = SecurityContext.CurrentAccount.ID;

            SaveComment(comment);
        }
Example #12
0
        public CommentInfo AddWikiComment(string parentcommentid, string entityid, string content)
        {
            CommunitySecurity.DemandPermissions(ASC.Web.Community.Wiki.Common.Constants.Action_AddComment);


            var parentIdGuid = String.IsNullOrEmpty(parentcommentid) ? Guid.Empty : new Guid(parentcommentid);
            var newComment   = _engine.CreateComment(new Comment {
                Body = content, PageName = entityid, ParentId = parentIdGuid
            });

            return(GetCommentInfo(newComment));
        }
Example #13
0
        public EventWrapperFull UpdateEvent(int feedid, string content, string title, FeedType type)
        {
            var feed = FeedStorage.GetFeed(feedid).NotFoundIfNull();

            CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

            feed.Caption = title;
            feed.Text    = content;
            feed.Creator = SecurityContext.CurrentAccount.ID.ToString();

            FeedStorage.SaveFeed(feed, true, type);

            return(new EventWrapperFull(feed));
        }
Example #14
0
        private void SaveComment(Comment comment)
        {
            CommunitySecurity.DemandPermissions(comment, Constants.Action_EditRemoveComment);

            if (String.IsNullOrEmpty(comment.Content))
            {
                throw new ArgumentException("comment");
            }
            if (comment.PostId == Guid.Empty)
            {
                throw new ArgumentException("comment");
            }

            _storage.GetPostDao().SaveComment(comment);
        }
Example #15
0
        protected void lbtnRemove_Click(object sender, EventArgs e)
        {
            var storage = StorageFactory.GetStorage();
            var store   = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo");

            if (!String.IsNullOrEmpty(AlbumID))
            {
                album = storage.GetAlbum(Convert.ToInt64(AlbumID));

                CommunitySecurity.DemandPermissions(album, PhotoConst.Action_EditRemovePhoto);

                store.DeleteFiles(PhotoConst.ImagesPath + album.UserID + "/" + album.Id + "/", "*", false);
                storage.RemoveAlbum(album.Id);

                Response.Redirect(PhotoConst.PAGE_PHOTO);
            }
        }
Example #16
0
        public EventWrapperFull DeleteEvent(int feedid)
        {
            var feed = FeedStorage.GetFeed(feedid).NotFoundIfNull();

            CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

            foreach (var comment in FeedStorage.GetFeedComments(feedid))
            {
                CommonControlsConfigurer.FCKUploadsRemoveForItem("news_comments", comment.Id.ToString(CultureInfo.InvariantCulture));
            }

            FeedStorage.RemoveFeed(feed);

            CommonControlsConfigurer.FCKUploadsRemoveForItem("news", feedid.ToString(CultureInfo.InvariantCulture));

            return(null);
        }
Example #17
0
        public string RemoveComment(string commentID, string pid)
        {
            CommunitySecurity.DemandPermissions(PhotoConst.Action_EditRemoveComment);

            long commentId;

            if (!string.IsNullOrEmpty(commentID) && long.TryParse(commentID, out commentId))
            {
                var storage = StorageFactory.GetStorage();
                var comment = storage.GetComment(commentId);
                var item    = storage.GetAlbumItem(comment.ItemID);

                storage.RemoveComment(commentId);

                PhotoUserActivityPublisher.RemoveComment(item, comment, SecurityContext.CurrentAccount.ID);
            }
            return(commentID);
        }
Example #18
0
        public string SaveEvent(long id, string name, string description, string dateTime)
        {
            var storage = StorageFactory.GetStorage();
            var Event   = storage.GetEvent(id);

            CommunitySecurity.DemandPermissions(Event, PhotoConst.Action_EditRemoveEvent);

            DateTime date;

            DateTime.TryParse(dateTime, out date);

            Event.Name        = GetLimitedText(name);
            Event.Description = GetLimitedText(description);
            Event.Timestamp   = date;

            storage.SaveEvent(Event);

            return(id.ToString());
        }
Example #19
0
        public AjaxResponse Remove(string id)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs1 = "0";
            if (!string.IsNullOrEmpty(id))
            {
                CommunitySecurity.DemandPermissions(NewsConst.Action_Edit);

                var storage = FeedStorageFactory.Create();
                storage.RemoveFeed(Convert.ToInt64(id, CultureInfo.CurrentCulture));

                CommonControlsConfigurer.FCKUploadsRemoveForItem("news", id);

                resp.rs1 = id;
                resp.rs2 = NewsResource.FeedDeleted;
            }
            return(resp);
        }
Example #20
0
        public void SaveEvent(Event ev)
        {
            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddEvent);

            if (ev == null)
            {
                throw new ArgumentNullException("event");
            }

            ev.Id = DbManager.ExecuteScalar <long>(
                Insert("photo_event")
                .InColumns(Mappers.EventColumns)
                .Values(ev.Id, ev.Name, ev.Description, ev.UserID, PrepareTimestamp(ev.Timestamp))
                .Identity <long>(1, 0, true)
                );

            var subscriber = NotifySource.GetSubscriptionProvider();

            subscriber.Subscribe(PhotoConst.NewEventComment, ev.Id.ToString(), NotifySource.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString()));
        }
Example #21
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = commentID
            };

            Guid?id = null;

            try
            {
                if (!String.IsNullOrEmpty(commentID))
                {
                    id = new Guid(commentID);
                }
            }
            catch
            {
                return(new AjaxResponse());
            }

            var engine = GetEngine();

            var comment = engine.GetCommentById(id.Value);

            if (comment == null)
            {
                throw new ApplicationException("Comment not found");
            }

            CommunitySecurity.DemandPermissions(comment, Constants.Action_EditRemoveComment);

            comment.Content = HtmlUtility.GetFull(text);

            var post = engine.GetPostById(comment.PostId);

            engine.UpdateComment(comment, post);

            resp.rs2 = text + CodeHighlighter.GetJavaScriptLiveHighlight(true);

            return(resp);
        }
Example #22
0
        public CommentInfo AddBlogComment(string parentcommentid, string entityid, string content)
        {
            Guid postId;
            Guid?parentId = null;

            postId = new Guid(entityid);
            if (!String.IsNullOrEmpty(parentcommentid))
            {
                parentId = new Guid(parentcommentid);
            }


            var post = BlogEngine.GetPostById(postId);

            if (post == null)
            {
                throw new Exception("postDeleted");
            }

            CommunitySecurity.DemandPermissions(post, ASC.Blogs.Core.Constants.Action_AddComment);

            var newComment = new Comment
            {
                PostId   = postId,
                Content  = content,
                Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                UserID   = SecurityContext.CurrentAccount.ID
            };

            if (parentId.HasValue)
            {
                newComment.ParentId = parentId.Value;
            }

            BlogEngine.SaveComment(newComment, post);

            //mark post as seen for the current user
            BlogEngine.SavePostReview(post, SecurityContext.CurrentAccount.ID);

            return(GetCommentInfo(newComment, false));
        }
Example #23
0
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var pageName = ((LinkButton)sender).CommandName;

                var page = Wiki.GetPage(pageName);
                CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(page), Common.Constants.Action_RemovePage);

                foreach (var comment in Wiki.GetComments(pageName))
                {
                    CommonControlsConfigurer.FCKUploadsRemoveForItem("wiki_comments", comment.Id.ToString());
                }
                Wiki.RemovePage(pageName);
                BindRepeater();
            }
            catch (Exception err)
            {
                WikiMaster.PrintInfoMessage(err.Message, InfoType.Warning);
            }
        }
Example #24
0
        public Comment UpdateComment(Comment comment)
        {
            var toUpdate = GetComment(comment.Id);

            if (toUpdate == null)
            {
                throw new ItemNotFoundException("comment not found");
            }
            if (String.IsNullOrEmpty(comment.Body))
            {
                throw new ArgumentException(@"comment content cannot be empty", "comment");
            }

            CommunitySecurity.DemandPermissions(new WikiObjectsSecurityObject(toUpdate), ASC.Web.Community.Wiki.Common.Constants.Action_EditRemoveComment);

            toUpdate.Body   = comment.Body;
            toUpdate.UserId = SecurityContext.CurrentAccount.ID;
            toUpdate.Date   = TenantUtil.DateTimeNow();

            return(SaveComment(toUpdate));
        }
Example #25
0
        private void DeletePhoto(AlbumItem image)
        {
            CommunitySecurity.DemandPermissions(image, PhotoConst.Action_EditRemovePhoto);

            var storage   = StorageFactory.GetStorage();
            var store     = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo");
            var tempAlbum = image.Album;

            if (image.Album.FaceItem.Equals(image))
            {
                var items = storage.GetAlbumItems(tempAlbum);
                tempAlbum.FaceItem = items[items[0].Equals(image) && 1 < tempAlbum.ImagesCount ? 1 : 0];
                storage.SaveAlbum(tempAlbum);
            }

            RemoveCommentsFCKUploads(storage.GetComments(image.Id));
            storage.RemoveAlbumItem(image.Id);

            store.Delete(PhotoConst.ImagesPath + image.ExpandedStoreThumb);
            store.Delete(PhotoConst.ImagesPath + image.ExpandedStorePreview);
        }
Example #26
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            CommunitySecurity.DemandPermissions(PhotoConst.Action_EditRemoveComment);

            var resp = new AjaxResponse {
                rs1 = commentID
            };

            var storage = StorageFactory.GetStorage();
            var comment = storage.GetComment(Convert.ToInt64(commentID));
            var image   = storage.GetAlbumItem(comment.ItemID);

            comment.Text = text;
            storage.SaveComment(image, comment);

            resp.rs2 = text;

            PhotoUserActivityPublisher.UpdateComment(image, comment, SecurityContext.CurrentAccount.ID);

            return(resp);
        }
Example #27
0
        public string CreateEvent(string name, string description, string dateTime)
        {
            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddEvent);

            var storage = StorageFactory.GetStorage();

            DateTime date;

            DateTime.TryParse(dateTime, out date);

            var item = new Event
            {
                Name        = GetLimitedText(name),
                Description = GetLimitedText(description),
                Timestamp   = date,
                UserID      = SecurityContext.CurrentAccount.ID.ToString()
            };

            storage.SaveEvent(item);

            return("<option value=\"" + item.Id.ToString() + "\" onclick=\"javascript:PhotoManager.LoadEvent(" + item.Id.ToString() + ");\">" + HttpUtility.HtmlEncode(item.Name) + "</option>");
        }
Example #28
0
        public EventWrapperFull CreateEvent(string content, string title, FeedType type)
        {
            CommunitySecurity.DemandPermissions(NewsConst.Action_Add);

            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException("Can't create feed with empty title", "title");
            }

            var feed = new Web.Community.News.Code.Feed
            {
                Caption  = title,
                Text     = content,
                Creator  = SecurityContext.CurrentAccount.ID.ToString(),
                Date     = DateTime.UtcNow,
                FeedType = type
            };

            FeedStorage.SaveFeed(feed, false, type);

            return(new EventWrapperFull(feed));
        }
Example #29
0
        public string RemoveEvent(long id)
        {
            var storage = StorageFactory.GetStorage();
            var Event   = storage.GetEvent(id);

            CommunitySecurity.DemandPermissions(Event, PhotoConst.Action_EditRemoveEvent);
            var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo");

            foreach (var album in storage.GetAlbums(id, null))
            {
                var pathAlbum = PhotoConst.ImagesPath + album.UserID + "/" + album.Id + "/";

                store.DeleteFiles(pathAlbum, "*", false);
            }

            var _storage             = StorageFactory.GetStorage();
            var subscriptionProvider = _storage.NotifySource.GetSubscriptionProvider();

            subscriptionProvider.UnSubscribe(PhotoConst.NewEventComment, id.ToString());

            storage.RemoveEvent(Event.Id);

            return(id.ToString()); //RenderEvents();
        }
Example #30
0
        public EventWrapperFull UpdateEvent(int feedid, string content, string title, FeedType type)
        {
            var feed = FeedStorage.GetFeed(feedid).NotFoundIfNull();

            CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException("Can't update feed with empty title", "title");
            }

            if (type != FeedType.News && type != FeedType.Order && type != FeedType.Advert && type != FeedType.Poll)
            {
                throw new ArgumentOutOfRangeException(string.Format("Unknown feed type: {0}.", type));
            }

            feed.Caption = title;
            feed.Text    = content;
            feed.Creator = SecurityContext.CurrentAccount.ID.ToString();

            FeedStorage.SaveFeed(feed, true, type);

            return(new EventWrapperFull(feed));
        }