//  public override void Insert(LoadResult result)
        //  {
        //     base.Insert(result);
        //     if (result.Cargos != null && result.Cargos.Count > 0)
        //     {
        //        foreach (CargoResult c in result.Cargos)
        //        {
        //            c.LoadId = result.Id;
        //            CargoManager.I.Insert(c);
        //         }
        //      }
        //  }
        //
        //  public override void Update(LoadResult result)
        //  {
        //      base.Update(result);
        //      if (result.Cargos != null && result.Cargos.Count > 0)
        //      {
        //          CargoManager.I.Update(result.Cargos);
        //      }
        //  }
        public void Upsert(AttendeesCodeCampYearResult result)
        {
            var meta = new CodeCampDataContext();

            var attendeesCodeCampYear = (from data in meta.AttendeesCodeCampYear
                                         where data.CodeCampYearId == result.CodeCampYearId && data.AttendeesId == result.AttendeesId
                                         select data).SingleOrDefault();

            if (attendeesCodeCampYear != null)
            {
                attendeesCodeCampYear.AttendSaturday = result.AttendSaturday;
                attendeesCodeCampYear.AttendSunday = result.AttendSunday;
            }
            else
            {
                attendeesCodeCampYear = new AttendeesCodeCampYear()
                {
                    AttendeesId = result.AttendeesId,
                    CodeCampYearId = result.CodeCampYearId,
                    AttendSaturday = result.AttendSaturday,
                    AttendSunday = result.AttendSunday
                };
                meta.AttendeesCodeCampYear.InsertOnSubmit(attendeesCodeCampYear);
            }
            meta.SubmitChanges();
        }
        public void UpdateWithAttendeeCCY(AttendeesResult attendeesResult)
        {
            base.Update(attendeesResult);

            if (!attendeesResult.CurrentCodeCampYear.HasValue)
            {
                throw new ApplicationException("IncludeAttendeesCodeCampYearResult seet on AttendeesManager but CurrentCodeCampYear Not also set and is required");
            }

            var rec = AttendeesCodeCampYearManager.I.Get(new AttendeesCodeCampYearQuery
                                                             {
                                                                 AttendeesId = attendeesResult.Id,
                                                                 CodeCampYearId = attendeesResult.CurrentCodeCampYear
                                                             }).FirstOrDefault();
            if (rec != null)
            {
                rec.Volunteer = attendeesResult.VolunteeredCurrentYear;
                rec.AttendingDaysChoice = attendeesResult.AttendingDaysChoiceCurrentYear;
                AttendeesCodeCampYearManager.I.Update(rec);
            }
            else
            {
                var newRec = new AttendeesCodeCampYearResult()
                                 {
                                     CreateDate = DateTime.Now,
                                     CodeCampYearId = attendeesResult.CurrentCodeCampYear.Value,
                                     Volunteer = attendeesResult.VolunteeredCurrentYear,
                                     AttendingDaysChoice = attendeesResult.AttendingDaysChoiceCurrentYear,
                                     AttendeesId = attendeesResult.Id
                                 };
                AttendeesCodeCampYearManager.I.Insert(newRec);
            }
        }