Example #1
0
        public void FireAfterMarkedAsSolution(object sender, MarkedAsSolutionEventArgs eventArgs)
        {
            var handler = AfterMarkedAsSolution;

            if (handler != null)
            {
                handler(this, eventArgs);
            }
        }
Example #2
0
        /// <summary>
        /// Mark a topic as solved
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="post"></param>
        /// <param name="marker"></param>
        /// <param name="solutionWriter"></param>
        /// <returns>True if topic has been marked as solved</returns>
        public bool SolveTopic(Topic topic, Post post, MembershipUser marker, MembershipUser solutionWriter)
        {
            var solved = false;

            var e = new MarkedAsSolutionEventArgs
                        {
                            Topic = topic,
                            Post = post,
                            Marker = marker,
                            SolutionWriter = solutionWriter
                        };
            EventManager.Instance.FireBeforeMarkedAsSolution(this, e);

            if (!e.Cancel)
            {
                // Make sure this user owns the topic, if not do nothing
                if (topic.User.Id == marker.Id)
                {
                    // Update the post
                    post.IsSolution = true;
                    //_postRepository.Update(post);

                    // Update the topic
                    topic.Solved = true;
                    //SaveOrUpdate(topic);

                    // Assign points
                    // Do not give points to the user if they are marking their own post as the solution
                    if (marker.Id != solutionWriter.Id)
                    {
                        _membershipUserPointsService.Add(new MembershipUserPoints
                                                             {
                                                                 Points = _settingsService.GetSettings().PointsAddedForSolution,
                                                                 User = solutionWriter
                                                             });
                    }

                    EventManager.Instance.FireAfterMarkedAsSolution(this, new MarkedAsSolutionEventArgs
                                                                              {
                                                                                  Topic = topic,
                                                                                  Post = post,
                                                                                  Marker = marker,
                                                                                  SolutionWriter = solutionWriter
                                                                              });
                    solved = true;
                }
            }

            return solved;
        }
 private void eventsService_AfterMarkedAsSolution(object sender, MarkedAsSolutionEventArgs args)
 {
     args.SolutionWriter.Email = TestString;
 }
 private void eventsService_BeforeMarkedAsSolutionAllow(object sender, MarkedAsSolutionEventArgs args)
 {
     args.Cancel = false;
 }
 private void eventsService_BeforeMarkedAsSolutionCancel(object sender, MarkedAsSolutionEventArgs args)
 {
     args.Cancel = true;
 }
Example #6
0
        public void FireAfterMarkedAsSolution(object sender, MarkedAsSolutionEventArgs eventArgs)
        {
            var handler = AfterMarkedAsSolution;

            if (handler != null)
            {
                handler(this, eventArgs);
            }
        }