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; }
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); } }
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; }
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; }
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; }
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; }
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"); } }
/// <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; }
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; }
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; }
/// <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); }
public Town Save(ListenTo.Shared.Interfaces.DO.IDO dO, UserCredentials userCredentials) { throw new NotImplementedException(); }
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; }
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; }
public void Delete(Guid id, UserCredentials userCredentials) { throw new NotImplementedException(); }
public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials) { return this.IsOwner<ITrackManager, Track>((Track)domainObject, userCredentials, TrackManager); }
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"); } }
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); }
/// <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; }
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; }
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); } }
public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials) { return this.IsOwner<ICommentManager, Comment>((Comment)domainObject, userCredentials, CommentManager); }
public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials) { return this.IsOwner<IArtistManager, Artist>((Artist)domainObject, userCredentials, ArtistManager); }
public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials) { return this.IsOwner<IVenueManager, Venue>((Venue)domainObject, userCredentials, VenueManager); }
public bool IsOwner(BaseDO domainObject, UserCredentials userCredentials) { return this.IsOwner<IGigManager, Gig>((Gig)domainObject, userCredentials, GigManager); }