예제 #1
0
        /*
         * Method name: SaveNew Event
         * Purpose: To save a new picture event
         */
        public bool SaveNewEvent(bool ticked)
        {
            Database.Database db         = new Database.Database(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3");
            StoryEvent        storyEvent = new StoryEvent
            {
                Value    = DateTime.Now.ToLongTimeString() + "-" + "Picture Taken",
                DateTime = DateTime.Now,
                Finished = ticked
            };

            var picture = new Picture {
                EventId = storyEvent.Id,
                Path    = GetImageUrl()
            };

            return(db.InsertEvent(true, storyEvent, null, picture, null) != 0);
        }
예제 #2
0
        /*
         * Method name: SaveExistingEvent
         * Purpose: To save a picture to an existing event
         */
        public bool SaveExistingEvent(SpinnerComponent spinner, bool ticked)
        {
            Database.Database db = new Database.Database(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3");
            var storyEvent       = db.FindEventByValue(spinner.GetSelected());

            if (storyEvent.InStory)
            {
                return(false);
            }
            else
            {
                storyEvent.Finished = ticked;

                var picture = new Picture {
                    EventId = storyEvent.Id,
                    Path    = GetImageUrl(),
                };

                return(db.InsertEvent(false, storyEvent, null, picture, null) != 0);
            }
        }
예제 #3
0
        /*
         * Method Name: InsertEvent
         * Purpose: To insert an event into the event table
         */
        public int InsertEvent(Boolean newEvent, StoryEvent storyEvent, Card card, Picture picture, List <Models.VoiceRecording> voiceRecording)
        {
            int count = 0;
            var db    = CreateConnection();

            if (newEvent)
            {
                count += db.Insert(storyEvent);
            }

            if (card != null)
            {
                count += db.Insert(card);

                if (storyEvent.Cards == null || storyEvent.Cards.Count.Equals(0))
                {
                    storyEvent.Cards = new List <Card> {
                        card
                    };
                }
                else
                {
                    storyEvent.Cards.Add(card);
                }
            }

            if (picture != null)
            {
                count += db.Insert(picture);
                if (storyEvent.Pictures == null || storyEvent.Pictures.Count.Equals(0))
                {
                    storyEvent.Pictures = new List <Picture> {
                        picture
                    };
                }
                else
                {
                    storyEvent.Pictures.Add(picture);
                }
            }

            if (voiceRecording != null)
            {
                foreach (var i in voiceRecording)
                {
                    count = +db.Insert(i);
                }
                if (storyEvent.VoiceRecordings == null || storyEvent.VoiceRecordings.Count.Equals(0))
                {
                    storyEvent.VoiceRecordings = new List <Models.VoiceRecording>();
                    foreach (var i in voiceRecording)
                    {
                        storyEvent.VoiceRecordings.Add(i);
                    }
                }
                else
                {
                    foreach (var i in voiceRecording)
                    {
                        storyEvent.VoiceRecordings.Add(i);
                    }
                }
            }
            db.UpdateWithChildren(storyEvent);

            db.Close();
            return(count);
        }