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; }
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 Site Save(IDO dO, UserCredentials userCredentials) { throw new NotImplementedException(); }
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"); } }