Ejemplo n.º 1
0
 public UserProfile SetUsersProfileImage(UserProfile userProfile, byte[] data, UserCredentials userCredentials)
 {
     ListenTo.Shared.DO.Image image = ImageManager.HandleUploadedImage(data, userCredentials);
     userProfile.ProfileImage = image;
     this.Save(userProfile, userCredentials);
     return userProfile;
 }
Ejemplo n.º 2
0
 public void DeleteGigsAtVenue(Guid venueId, UserCredentials userCredentials)
 {
     IList<Gig> gigsAtVenue = this.Repository.GetGigsAtVenue(venueId);
     foreach (Gig gig in gigsAtVenue)
     {
         gig.IsDeleted = true;
         this.Save(gig, userCredentials);
     }
 }
Ejemplo n.º 3
0
        public ListenTo.Shared.DO.UserProfile Save(ListenTo.Shared.Interfaces.DO.IDO dO, UserCredentials userCredentials)
        {
            UserProfile userProfile = (UserProfile)dO;

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

               this.Repository.SaveUserProfile(userProfile);
               return userProfile;
        }
Ejemplo n.º 4
0
 public ListenToUser(MembershipUser membershipUser, IUserManager userManager)
 {
     this._membershipUser = membershipUser;
     Guid id = (Guid)this._membershipUser.ProviderUserKey;
     _user = userManager.GetByID(id);
     _identity = new System.Security.Principal.GenericIdentity(this._membershipUser.UserName);
     _userCredentials = new UserCredentials();
     _userCredentials.Username = _user.Username;
     _userCredentials.Password = _user.Password;
 }
Ejemplo n.º 5
0
        public bool CheckOwnership(ListenTo.Shared.DO.BaseDO baseDO, UserCredentials userCredentials)
        {
            IOwnershipHelper helper = OwnershipHelperFactory.CreateHelper(baseDO);
            bool isOwner = helper.IsOwner(baseDO, userCredentials);

            if (isOwner == false)
            {
                throw new Exception("The user does not own this object");
            }

            return isOwner;
        }
Ejemplo n.º 6
0
        public bool CheckIsNew(ListenTo.Shared.DO.BaseDO baseDO, UserCredentials userCredentials)
        {
            IIsNewHelper helper = IsNewHelperFactory.CreateHelper(baseDO);

            if (helper == null)
            {
                throw new Exception("There isnt a IsNewHelper defined for this");
            }

            bool isNew = helper.IsNew(baseDO, userCredentials);

            return isNew;
        }
Ejemplo n.º 7
0
 public void Delete(Guid id, UserCredentials userCredentials)
 {
     NewsItem newsItem = this.GetByID(id);
     if (newsItem != null)
     {
         this.CheckOwnership(newsItem, userCredentials);
         newsItem.IsDeleted = true;
         this.Save(newsItem, userCredentials);
     }
     else
     {
         throw new Exception("The newsitem you are trying to delete does not exist");
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseDO"></param>
        /// <param name="userCredentials">The credentials of the user who wants to access the object</param>
        /// <returns></returns>
        public bool IsOwner(ListenTo.Shared.DO.BaseDO baseDO, UserCredentials userCredentials)
        {
            IOwnershipHelper helper = OwnershipHelperFactory.CreateHelper(baseDO);

            if (helper == null)
            {
                throw new Exception("There isnt a IOwnershipHelper defined for this");
            }

            bool isOwner = helper.IsOwner(baseDO, userCredentials);

            if (isOwner == false)
            {
                throw new Exception("The user does not own this object");
            }

            return isOwner;
        }
Ejemplo n.º 9
0
        public void Delete(Guid id, UserCredentials userCredentials)
        {
            Venue venue = this.GetByID(id);
            if (venue != null)
            {
                this.CheckOwnership(venue, userCredentials);

                venue.IsDeleted = true;
                this.Save(venue, userCredentials);

                GigManager.DeleteGigsAtVenue(venue.ID, userCredentials);

            }
            else
            {
                throw new Exception("The venue you are trying to delete does not exist");
            }
        }
        public bool Validate(BaseDO domainObject, UserCredentials userCredentials)
        {
            IValidationHelper validationHelper;

            bool hasValidationHelper = HasValidationHelper(domainObject, out validationHelper);

            if (hasValidationHelper == false)
            {
                throw new Exception("The domain object doesnt have validtion helper");
            }

            ValidationStateDictionary validationStateDictionary = validationHelper.Validate(domainObject, userCredentials);
            if (validationStateDictionary.Count > 0)
            {
               throw new ValidationException(validationStateDictionary);
            }

               return true;
        }
Ejemplo n.º 11
0
        public Venue Save(IDO dO, UserCredentials userCredentials)
        {
            Venue venue = (Venue)dO;

            this.CheckOwnership(venue, userCredentials);

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

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

            if (isVenueNew)
            {
                //Persist the venue...
                this.Repository.SaveVenue(venue);
            }

            return venue;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a thumbnail from the passed image and persists the thumbnail and the original image
 /// </summary>
 /// <param name="image"></param>
 public void HandleUploadedImage(ListenTo.Shared.DO.Image image, UserCredentials userCredentials)
 {
     ListenTo.Shared.DO.Image thumbnailImage = CreateThumbnailImage(image);
     image.Thumbnail = thumbnailImage;
     this.Save(thumbnailImage, userCredentials);
     this.Save(image, userCredentials);
 }
Ejemplo n.º 13
0
 public Town Save(ListenTo.Shared.Interfaces.DO.IDO dO, UserCredentials userCredentials)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
0
 public NewsItem SetNewsItemImage(NewsItem newsitem, byte[] data, UserCredentials userCredentials)
 {
     ListenTo.Shared.DO.Image image = ImageManager.HandleUploadedImage(data, userCredentials);
     newsitem.Image = image;
     this.Save(newsitem, userCredentials);
     return newsitem;
 }
Ejemplo n.º 16
0
 public void Delete(Guid id, UserCredentials userCredentials)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<ITrackManager, Track>((Track)domainObject, userCredentials, TrackManager);
 }
Ejemplo n.º 18
0
        public void NewUserStrategy(IDO dO, UserCredentials userCredentials)
        {
            User userDO = (User)dO;

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

            //Does this user already exist?
            User preExistinUser = Repository.GetUsers().WithID(userDO.ID).SingleOrDefault();

            if (preExistinUser == null)
            {
                //This user is new. It cannot be validated, so if the validation flag is set to true, reset it
                userDO.IsValidated = false;
                //Ensure we store the email address as lower case etc...
                userDO.EmailAddress = userDO.EmailAddress.ToLower().Trim();
                //Persist the user
                Repository.SaveUser(userDO);

                //Send the request for validation email
                UserApprovalStrategy.RequestApproval(userDO);
            }
            else
            {
                throw new Exception("This user is NOT new and cannot be handled by HandleNewUserProcess");
            }
        }
Ejemplo n.º 19
0
 public Site Save(IDO dO, UserCredentials userCredentials)
 {
     throw new NotImplementedException();
 }
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<INewsItemManager, NewsItem>((NewsItem)domainObject, userCredentials, NewsItemManager);
 }
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<IUserProfileManager, UserProfile>((UserProfile)domainObject, userCredentials, UserProfileManager);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="image"></param>
        public Image HandleUploadedImage(byte[] data, UserCredentials userCredentials)
        {
            ListenTo.Shared.DO.Image image = new Image();
            image.Data = data;

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

            //Construct an image object which contains all the meta data...
            image = Shared.Helpers.ImageHelpers.GetImage(image.Data);

            HandleUploadedImage(image, userCredentials);
            return image;
        }
Ejemplo n.º 23
0
        public ListenTo.Shared.DO.Image Save(ListenTo.Shared.Interfaces.DO.IDO dO, UserCredentials userCredentials)
        {
            ListenTo.Shared.DO.Image image = (ListenTo.Shared.DO.Image)dO;

            string imagePath = ImageHelpers.ConstructImagePath(image);

            //If a file already exists, delete it...
            if (System.IO.File.Exists(imagePath))
            {
                System.IO.File.Delete(imagePath);
            }

            //Save the image for the web
            ImageHelpers.SaveForWeb(image.Data, imagePath);

            //System.IO.File.WriteAllBytes(imagePath, image.Data);
            this.Repository.SaveImageMetaData(Adapt(image));
            return image;
        }
Ejemplo n.º 24
0
        public void RetrieveDetailsFromEmailAddress(string emailAddress, UserCredentials userCredentials)
        {
            //Does this user already exist?
            User preExistinUser = Repository.GetUsers().WithEmailAddress(emailAddress).SingleOrDefault();

            if(preExistinUser!=null){
                RetrieveDetailsStrategy.RetrieveDetails(preExistinUser);
            }
        }
Ejemplo n.º 25
0
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<ICommentManager, Comment>((Comment)domainObject, userCredentials, CommentManager);
 }
Ejemplo n.º 26
0
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<IArtistManager, Artist>((Artist)domainObject, userCredentials, ArtistManager);
 }
Ejemplo n.º 27
0
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<IVenueManager, Venue>((Venue)domainObject, userCredentials, VenueManager);
 }
Ejemplo n.º 28
0
 public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials)
 {
     return this.IsOwner<IGigManager, Gig>((Gig)domainObject, userCredentials, GigManager);
 }