Пример #1
0
        public ActionResult ItemRedirect(ScheduleItemAddress scheduleItemAddress)
        {
            var url      = "/MIX10/Sessions/" + scheduleItemAddress.ScheduleItemSlug;
            var redirect = new PermanentRedirectResult(url);

            return(redirect);
        }
Пример #2
0
        private JsonResult ValidateScheduleItemAddress(ScheduleItemAddress scheduleItemAddress, out bool isValid)
        {
            var @event  = eventService.GetEvent(scheduleItemAddress.ToEventAddress());
            var success = new JsonResult {
                Data = new { result = "success" }
            };
            var failure = new JsonResult {
                Data = new { result = "error", message = "invalid data" }
            };

            if (@event == null)
            {
                isValid = false;
                return(failure);
            }

            var scheduleItem = scheduleItemService.GetScheduleItem(scheduleItemAddress);

            if (scheduleItem == null)
            {
                isValid = false;
                return(failure);
            }

            if (!context.User.IsAuthenticated)
            {
                isValid = false;
                return(failure);
            }

            isValid = true;
            return(success);
        }
Пример #3
0
        public ActionResult RemoveFromUser(ScheduleItemAddress scheduleItemAddress)
        {
            RemoveFromUserJson(scheduleItemAddress);

            var url = Request.UrlReferrer.AbsoluteUri;

            return(Redirect(url));
        }
Пример #4
0
        public void RemoveUserFromScheduleItem(ScheduleItemAddress scheduleItemAddress, Guid userID)
        {
            var scheduleItem = GetScheduleItem(scheduleItemAddress);

            repository.RemoveUserRelationship(scheduleItem.ToScheduleItemSmall(), userID);

            //cache.InvalidateItem(scheduleItem);
            //cache.Invalidate(string.Format("GetScheduleItemsByUser-UserID:{0}", userID));
        }
Пример #5
0
        public void AddUserToScheduleItem(ScheduleItemAddress scheduleItemAddress, Guid userID)
        {
            var scheduleItem = GetScheduleItem(scheduleItemAddress);

            repository.AddUserRelationship(scheduleItem.ToScheduleItemSmall(), userID);

            //cache.InvalidateItem(scheduleItem);
            //var key = string.Format("GetScheduleItemsByUser-UserID:{0}", userID);
            //cache.InvalidateContains(key, StringComparer.InvariantCultureIgnoreCase);
        }
Пример #6
0
        public ScheduleItem GetScheduleItem(ScheduleItemAddress scheduleItemAddress)
        {
            var result =
                cache.GetItem <ScheduleItem>(
                    string.Format("GetScheduleItem-Event:{0},ScheduleItem:{1}", scheduleItemAddress.EventName, scheduleItemAddress.ScheduleItemSlug),
                    () => repository.GetScheduleItem(scheduleItemAddress.EventName, scheduleItemAddress.ScheduleItemSlug).FillTags(tagService).FillComments(commentService),
                    si => si.GetDependencies()
                    );

            SetScheduleItemUsers(result);

            return(result);
        }
Пример #7
0
        public object AddComment(ScheduleItemAddress scheduleItemAddress, CommentInput commentInput)
        {
            if (context.Site.CommentingDisabled)
            {
                return(null);
            }

            Event evnt = eventService.GetEvent(scheduleItemAddress.ToEventAddress());

            if (evnt == null)
            {
                return(null);
            }

            ScheduleItem scheduleItem = scheduleItemService.GetScheduleItem(scheduleItemAddress);

            if (scheduleItem == null)
            {
                return(null);
            }

            ModelResult <ScheduleItemComment> addCommentResults = commentService.AddComment(scheduleItemAddress, commentInput);

            if (!addCommentResults.IsValid)
            {
                ModelState.AddModelErrors(addCommentResults.ValidationState);

                return(Item(scheduleItemAddress));
            }

            if (!context.User.IsAuthenticated)
            {
                if (commentInput.SaveAnonymousUser)
                {
                    Response.Cookies.SetAnonymousUser(commentInput.Creator);
                }
                else if (Request.Cookies.GetAnonymousUser() != null)
                {
                    Response.Cookies.ClearAnonymousUser();
                }
            }

            return(new RedirectResult(
                       addCommentResults.Item.State != EntityState.PendingApproval
                ? Url.Comment(addCommentResults.Item)
                : Url.CommentPending(addCommentResults.Item)
                       ));
        }
        private string generateUniqueCommentSlug(ScheduleItemAddress scheduleItemAddress)
        {
            string commentSlug = null;
            bool   isUnique    = false;

            while (!isUnique)
            {
                commentSlug = Guid.NewGuid().ToString("N").Substring(0, 5);

                ScheduleItemComment foundComment = getComment(new ScheduleItemCommentAddress(scheduleItemAddress, commentSlug));

                isUnique = foundComment == null;
            }

            return(commentSlug);
        }
Пример #9
0
        public JsonResult RemoveFromUserJson(ScheduleItemAddress scheduleItemAddress)
        {
            bool isValid;
            var  result = ValidateScheduleItemAddress(scheduleItemAddress, out isValid);

            if (!isValid)
            {
                return(result);
            }

            var user   = context.User.Cast <UserAuthenticated>();
            var userId = user != null ? user.ID : Guid.Empty;

            scheduleItemService.RemoveUserFromScheduleItem(scheduleItemAddress, userId);
            return(result);
        }
Пример #10
0
        private OxiteViewModelItem <ScheduleItem> ItemImpl(ScheduleItemAddress scheduleItemAddress)
        {
            Event evnt = eventService.GetEvent(scheduleItemAddress.ToEventAddress());

            if (evnt == null)
            {
                return(null);
            }

            ScheduleItem scheduleItem = scheduleItemService.GetScheduleItem(scheduleItemAddress);

            if (scheduleItem == null)
            {
                return(null);
            }

            bool includeUnapproved = context.User.IsAuthenticated && context.User.IsInRole("Admin");

            return(new OxiteViewModelItem <ScheduleItem>(scheduleItem)
            {
                Container = scheduleItem.Event
            });
        }
        public ModelResult <ScheduleItemComment> AddComment(ScheduleItemAddress scheduleItemAddress, CommentInput commentInput)
        {
            CommentIn commentIn = new CommentIn(commentInput);

            pluginEngine.ExecuteAll("ProcessInputOfComment", new { context, comment = commentIn });
            commentInput = commentIn.ToCommentInput();

            commentInput = pluginEngine.Process <CommentIn>("ProcessInputOfCommentOnAdd", new CommentIn(commentInput)).ToCommentInput();

            if (pluginEngine.AnyTrue("IsCommentSpam", new { context, comment = commentIn }))
            {
                return(new ModelResult <ScheduleItemComment>(new ValidationStateDictionary(typeof(CommentInput), new ValidationState(new[] { new ValidationError("Comment.IsSpam", commentInput, "The supplied comment was considered to be spam and was not added") }))));
            }

            ValidationStateDictionary validationState = ValidateCommentInput(commentInput);

            if (!validationState.IsValid)
            {
                return(new ModelResult <ScheduleItemComment>(validationState));
            }

            EntityState commentState;

            try
            {
                commentState = context.User.IsAuthenticated ? EntityState.Normal : (EntityState)Enum.Parse(typeof(EntityState), context.Site.CommentStateDefault);
            }
            catch
            {
                commentState = EntityState.PendingApproval;
            }

            //TODO: (erikpo) Replace with some logic to set the language from the user's browser or from a dropdown list
            Language            language = languageRepository.GetLanguage(context.Site.LanguageDefault ?? "en");
            ScheduleItemComment comment;

            using (TransactionScope transaction = new TransactionScope())
            {
                string commentSlug = generateUniqueCommentSlug(scheduleItemAddress);

                comment = commentInput.ToComment(context.User.Cast <UserAuthenticated>(), context.HttpContext.Request.GetUserIPAddress().ToLong(), context.HttpContext.Request.UserAgent, language, commentSlug, commentState);

                comment = conferencesCommentRepository.Save(comment, context.Site.ID, scheduleItemAddress.EventName, scheduleItemAddress.ScheduleItemSlug);

                if (comment.State == EntityState.Normal)
                {
                    invalidateCachedCommentDependencies(comment);
                }

                transaction.Complete();
            }

            //TODO: (erikpo) The following calls to setup the subscription and send out emails for those subscribed needs to happen in the transaction (but can't currently because of issues with them being in different repositories

            //TODO: (erikpo) Move into a module
            if (commentInput.Subscribe)
            {
                if (context.User.IsAuthenticated)
                {
                    scheduleItemRepository.AddSubscription(context.Site.ID, comment.ScheduleItem, comment.CreatorUserID);
                }
                else
                {
                    scheduleItemRepository.AddSubscription(context.Site.ID, comment);
                }
            }

            //TODO: (erikpo) Move into a module
            messageOutboundRepository.Save(generateMessages(comment.ScheduleItem, comment));

            ScheduleItemSmallReadOnly scheduleItemProxy = new ScheduleItemSmallReadOnly(comment.ScheduleItem);
            CommentReadOnly           commentProxy      = new CommentReadOnly(comment, "");

            pluginEngine.ExecuteAll("CommentAdded", new { context, parent = scheduleItemProxy, comment = commentProxy });

            if (comment.State == EntityState.Normal)
            {
                pluginEngine.ExecuteAll("CommentApproved", new { context, parent = scheduleItemProxy, comment = commentProxy });
            }

            return(new ModelResult <ScheduleItemComment>(comment, validationState));
        }
Пример #12
0
 public ScheduleItemCommentAddress(ScheduleItemAddress scheduleItemAddress, string commentSlug)
     : this(scheduleItemAddress.EventName, scheduleItemAddress.ScheduleItemSlug, commentSlug)
 {
 }
Пример #13
0
 public OxiteViewModelItem <ScheduleItem> ItemJson(ScheduleItemAddress scheduleItemAddress)
 {
     return(ItemImpl(scheduleItemAddress));
 }