예제 #1
0
        /// <summary>
        /// Approves the user for login
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool Approve(string key)
        {
            bool approved = false;
            User user = UserApprovalStrategy.Approve(key);
            if (user != null && user.IsValidated == true)
            {
                approved = true;
                this.Repository.SaveUser(user);

                //Add action....
                ListenTo.Shared.DO.Action action = new ListenTo.Shared.DO.Action();
                action.ActionType = ActionType.JOINED;
                action.ContentType = ContentType.USER;
                action.ContentID = user.ID;
                action.OwnerID = user.ID;
                ActionsManager.AddAction(action, null);

            }

            return approved;
        }
        /// <summary>
        /// Constructs an action for a comment associated with a news item
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public ListenTo.Shared.DO.Action BuildAction(ListenTo.Shared.DO.Comment comment)
        {
            //Load the content so we can determine the site its associated with
            NewsItem newsItem = NewsItemManager.GetByID(comment.TargetId);

            if (newsItem == null)
            {
                throw new Exception("Cannot create Action for NewsItem Comment. NewsItem does not exist");
            }

            ListenTo.Shared.DO.Action action = new ListenTo.Shared.DO.Action();
            action.ContentID = comment.ID;
            action.ContentType = ContentType.COMMENT;
            action.ActionType = ActionType.COMMENTED_ON_A_NEWSITEM;
            action.Created = DateTime.Now;
            action.TargetSites = new List<Guid>();
            action.OwnerID = comment.OwnerID;
            foreach(Site site in newsItem.TargetSites){
                action.TargetSites.Add(site.ID);
            }

            return action;
        }
        public ListenTo.Shared.DO.Action BuildAction(ListenTo.Shared.DO.Comment comment)
        {
            //Load the content so we can determine the site its associated with
            UserProfile userProfile = UserProfileManager.GetByID(comment.TargetId);

            if (userProfile == null)
            {
                throw new Exception("Cannot create Action for UserProfile Comment. UserProfile does not exist");
            }

            ListenTo.Shared.DO.Action action = new ListenTo.Shared.DO.Action();
            action.ContentID = comment.ID;
            action.ContentType = ContentType.COMMENT;
            action.ActionType = ActionType.COMMENTED_ON_A_USERPROFILE;
            action.Created = DateTime.Now;
            action.TargetSites = new List<Guid>();
            action.OwnerID = comment.OwnerID;

            foreach(Site site in userProfile.Town.Sites){
                action.TargetSites.Add(site.ID);
            }

            return action;
        }
예제 #4
0
        public ListenTo.Shared.DO.NewsItem Save(ListenTo.Shared.Interfaces.DO.IDO dO, ListenTo.Shared.DO.UserCredentials userCredentials)
        {
            NewsItem newsItem = (NewsItem)dO;

            this.CheckOwnership(newsItem, userCredentials);

            bool isValid = ValidationRunner.Validate(newsItem, userCredentials);

            bool isNew = this.CheckIsNew(newsItem, userCredentials);

            newsItem =  this.Repository.SaveNewsItem(newsItem);

            if (isNew)
            {
                ListenTo.Shared.DO.Action action = new ListenTo.Shared.DO.Action();
                action.ActionType = ActionType.ADDED_A_NEWS_ITEM;
                action.ContentType = ContentType.NEWSITEM;
                action.ContentID = newsItem.ID;

                foreach (Site site in newsItem.TargetSites)
                {
                    action.TargetSites.Add(site.ID);
                }

                action.OwnerID = newsItem.OwnerID;
                ActionsManager.AddAction(action, userCredentials);
            }

            return newsItem;
        }
예제 #5
0
        public Gig Save(IDO dO, UserCredentials userCredentials)
        {
            Gig gig = (Gig)dO;

            this.CheckOwnership(gig, userCredentials);

            //This will throw an exception if the data model is invalid.
            bool isValid = ValidationRunner.Validate(gig, userCredentials);

            //Its possible that the venue *may* be new, so we need to persist the new venue
            //first.
            bool isVenueNew = this.CheckIsNew(gig.Venue, userCredentials);

            if (isVenueNew)
            {
                //Persist the venue...
                this.VenueManager.Save(gig.Venue, userCredentials);
            }

            bool isNew = this.CheckIsNew(gig, userCredentials);

            gig = this.Repository.SaveGig(gig);

            if (isNew)
            {
                ListenTo.Shared.DO.Action action = new ListenTo.Shared.DO.Action();
                action.ActionType = ActionType.ADDED_A_GIG;
                action.ContentType = ContentType.GIG;
                action.ContentID = gig.ID;

                foreach (Site site in gig.Venue.Town.Sites)
                {
                    action.TargetSites.Add(site.ID);
                }

                action.OwnerID = gig.OwnerID;

                foreach (Act act in gig.Acts)
                {
                    if (act.Artist != null)
                    {
                        action.AssociatedArtistIds.Add(act.Artist.ID);
                    }
                }

                ActionsManager.AddAction(action, userCredentials);
            }

            return gig;
        }