示例#1
0
        /*
         * Method Name: UpdateStory
         * Purpose: To update a single story
         */
        public void UpdateStory(Models.Story story)
        {
            var db = CreateConnection();

            db.Update(story);
            db.Close();
        }
示例#2
0
        /*
         * Method Name: GetMostPlayed
         * Purpose: To return the story that has been the most played
         */
        public Models.Story GetMostPlayed()
        {
            var stories = GetAllStories();

            Models.Story story = new Models.Story();
            if (stories != null && !stories.Count.Equals(0))
            {
                int mostPlayed = stories.Max(j => j.TimesPlayed);
                story = stories.FirstOrDefault(i => i.TimesPlayed.Equals(mostPlayed));
            }
            return(story);
        }
示例#3
0
        /*
         * Method Name: InsertStories
         * Purpose: To insert a story into the story table
         */
        public int InsertStories(List <StoryEvent> storyEventList, bool isExtraStory, bool isTextToSpeech, string defaultPicture)
        {
            int count = 0;
            var db    = CreateConnection();
            var story = new Models.Story();

            count += db.Insert(story);
            bool firstPicture = false;
            bool firstCard    = false;

            foreach (var i in storyEventList)
            {
                if (i.Pictures != null && i.Pictures.Count != 0 && !firstPicture)
                {
                    story.CoverPhoto = i.Pictures[0].Path;
                    firstPicture     = true;
                }

                if (i.Cards != null && i.Cards.Count != 0 && !firstCard)
                {
                    story.TitleValue = i.Cards[0].Message;
                    firstCard        = true;
                }

                i.StoryId = story.Id;
                i.InStory = true;
                db.UpdateWithChildren(i);
            }

            if (firstCard.Equals(false))
            {
                story.TitleValue = "This happened at school today...";
            }

            story.Events = storyEventList;
            if (isExtraStory)
            {
                story.Extra = true;
            }

            if (isTextToSpeech)
            {
                story.TextToSpeech = true;
            }

            if (defaultPicture != null)
            {
                story.DefaultPicture = defaultPicture;
            }
            else
            {
                story.DefaultPicture = null;
            }

            story.DateTime  = DateTime.Now;
            story.Favourite = false;
            db.UpdateWithChildren(story);

            db.Close();

            return(count);
        }