Beispiel #1
0
        protected void Add_Story()
        {
            //make a new story object
            Story story = new Story();
            //set story's Title property to value from txtTitle
            story.Title = this.txtTitle.Value;
            //set story's Summary property to value from txtSummary
            story.Summary = this.txtSummary.Value;
            //set story's FandomID property to selected value of ddlFandom
            story.FandomID = new Guid(this.ddlFandom.SelectedValue);
            //set story's GenreID1 property to selected value of ddlGenre1
            story.GenreID1 = new Guid(this.ddlGenre1.SelectedValue);
            //set story's GenreID2 property to selected value of ddlGenre2
            story.GenreID2 = new Guid(this.ddlGenre2.SelectedValue);
            //set story's MaturityID property to selected value of ddlMaturityID
            story.MaturityID = new Guid(this.ddlMaturity.SelectedValue);
            //set stryUser UserID to the User's ID (stored in session)
            usersStories.UserID = userID;

            //if statement will run if story.IsSavable equals true
            if (story.IsSavable() == true)
            {
                //if the story is savable, save it
                story = story.Save();
                //set the storyID of stryUsers to the id of story
                usersStories.StoryID = story.Id;

                //make a new User called usr
                User usr = new User();
                //get the right user by userID (taken from Session["UserID"])
                usr = usr.GetById(userID);
                //set usr's StoryAmount property to equal itself plus 1
                usr.StoryAmount = usr.StoryAmount + 1;
                //set usersStories' UserId property to value of userID
                usersStories.UserID = userID;
                //call save_Bridges
                save_Bridges();
                //redirect user to AddChapter page
                Server.Transfer("AddChapter.aspx", true);
            }
        }