partial void DeleteSchedule(Schedule instance);
 partial void InsertSchedule(Schedule instance);
 partial void UpdateSchedule(Schedule instance);
        internal void SetAsFavorite(UnconferenceViewModel selectedUnconference)
        {
            using (DatabaseDataContext context = new DatabaseDataContext(Settings.ConnectionString))
            {
                var query = (from unconference in context.ScheduleByUnconferences
                            where unconference.PlaceId == selectedUnconference.Place.Identifier
                            && unconference.ScheduleId == selectedUnconference.Schedule.Identifier
                            && unconference.UnconferenceId == selectedUnconference.Identifier
                            select unconference).FirstOrDefault();

                if (query == null)
                {
                    var newPlace = (from p in context.Places
                                        where p.Identifier == selectedUnconference.Place.Identifier
                                        select p).FirstOrDefault();

                    if (newPlace == null)
                    {
                        newPlace = new Places()
                        {
                            Identifier = selectedUnconference.Place.Identifier,
                            Description = selectedUnconference.Place.Description,
                            Name = selectedUnconference.Place.Name,
                        };

                        context.Places.InsertOnSubmit(newPlace);
                        context.SubmitChanges();
                    }

                    var unconference = (from u in context.Unconferences
                                                where u.Identifier == selectedUnconference.Identifier
                                                select u).FirstOrDefault();

                    if (unconference == null)
                    {
                        Unconferences newUnconference = new Unconferences()
                        {
                            Description = selectedUnconference.Description,
                            Identifier = selectedUnconference.Identifier,
                            Keywords = selectedUnconference.Keywords,
                            Name = selectedUnconference.Name,
                            Speakers = selectedUnconference.Speakers,
                        };

                        context.Unconferences.InsertOnSubmit(newUnconference);
                        context.SubmitChanges();
                    }

                    var selectedSchedule = (from s in context.Schedules
                                            where s.Identifier == selectedUnconference.Schedule.Identifier
                                            select s).FirstOrDefault();

                    if (selectedSchedule == null)
                    {
                        Schedule newSchedule = new Schedule()
                        {
                            Identifier = selectedUnconference.Schedule.Identifier,
                            StartTime = selectedUnconference.Schedule.StartTime,
                            EndTime = selectedUnconference.Schedule.EndTime,
                        };
                        context.Schedules.InsertOnSubmit(newSchedule);
                        context.SubmitChanges();
                    }

                    ScheduleByUnconference newScheduleByUnconference = new ScheduleByUnconference()
                    {
                        ScheduleId = selectedUnconference.Schedule.Identifier,
                        UnconferenceId = selectedUnconference.Identifier,
                        PlaceId = selectedUnconference.Place.Identifier,
                    };

                    context.ScheduleByUnconferences.InsertOnSubmit(newScheduleByUnconference);
                    context.SubmitChanges();
                }

                context.SubmitChanges();
            }
        }