public virtual void Add(BoardMember member, IEnumerable<Skill> skills, IEnumerable<ServiceArea> serviceAreas)
        {
            using (var context = new SqlDataContext())
            {
                member.AvailableSkills.Clear();
                member.Interests.Clear();

                context.BoardMembers.Add(member);
                context.SaveChanges();

                if (skills != null && serviceAreas != null && member.AvailableSkills != null && member.Interests != null)
                {
                    member.AvailableSkills.Clear();
                    member.Interests.Clear();

                    var rawSkillIds = skills.Select(x => (int)x);
                    var rawServiceIds = serviceAreas.Select(x => (int)x);

                    var transformSkils = context.Skills.Where(x => rawSkillIds.Contains(x.SkillId)).ToList();
                    var transformAreas = context.ServiceAreas.Where(x => rawServiceIds.Contains(x.ServiceAreaId)).ToList();

                    transformSkils.ForEach(x => member.AvailableSkills.Add(x));
                    transformAreas.ForEach(x => member.Interests.Add(x));
                }

                context.SaveChanges();
            }
        }
        public virtual UpdateResult UpdateBoardMember(BoardMember member, IEnumerable<Skill> skills, IEnumerable<ServiceArea> serviceAreas)
        {
            if (_repository.GetSetOfBoardMembers(x => x.Email.ToLower() == member.Email.ToLower() && x.BoardMemberId != member.BoardMemberId).Any())
                return UpdateResult.ItemAlreadyExists;

            _repository.Update(member, skills, serviceAreas);

            return UpdateResult.Successful;
        }
        public virtual CreateResult CreateBoardMember(BoardMember member, IEnumerable<Skill> skills, IEnumerable<ServiceArea> serviceAreas)
        {
            if (_repository.GetSetOfBoardMembers(x => x.Email.ToLower() == member.Email.ToLower()).Any())
                return CreateResult.ItemAlreadyExists;

            _repository.Add(member, skills, serviceAreas);

            return CreateResult.SuccessfullyCreated;
        }
        public virtual void Update(BoardMember updatedMember, IEnumerable<Skill> skills, IEnumerable<ServiceArea> serviceAreas)
        {
            using (var context = new SqlDataContext())
            {
                var member = context.BoardMembers.First(x => x.BoardMemberId == updatedMember.BoardMemberId);

                member.Address1 = updatedMember.Address1;
                member.Address2 = updatedMember.Address2;
                member.City = updatedMember.City;
                member.Email = updatedMember.Email;
                member.Employer = updatedMember.Employer;
                member.FirstName = updatedMember.FirstName;
                member.LastName = updatedMember.LastName;
                member.Title = updatedMember.Title;
                member.Phone = updatedMember.Phone;
                member.PostalCode = updatedMember.PostalCode;
                member.State = updatedMember.State;
                member.Ethnicity = updatedMember.Ethnicity;
                member.Gender = updatedMember.Ethnicity;
                member.YearsService = updatedMember.YearsService;
                member.MissionStatement = updatedMember.MissionStatement;
                member.BirthDay = updatedMember.BirthDay;
                member.IsSearchable = updatedMember.IsSearchable;
                if (!String.IsNullOrWhiteSpace(updatedMember.Password))
                    member.Password = updatedMember.Password;

                if (skills != null && serviceAreas != null && member.AvailableSkills != null && member.Interests != null)
                {
                    member.AvailableSkills.Clear();
                    member.Interests.Clear();

                    var rawSkillIds = skills.Select(x => (int)x);
                    var rawServiceIds = serviceAreas.Select(x => (int)x);

                    var transformSkils = context.Skills.Where(x => rawSkillIds.Contains(x.SkillId)).ToList();
                    var transformAreas = context.ServiceAreas.Where(x => rawServiceIds.Contains(x.ServiceAreaId)).ToList();

                    transformSkils.ForEach(x => member.AvailableSkills.Add(x));
                    transformAreas.ForEach(x => member.Interests.Add(x));
                }

                context.SaveChanges();
            }
        }
        public void CanCrudBoardMembers()
        {
            Database.SetInitializer<SqlDataContext>(null);

            var dataContext = new SqlDataContext();

            //Insert!
            var member = new BoardMember
            {
                FirstName = "bob",
                LastName = "smith",
                BirthDay = DateTime.Now,
                Employer = "wut.com",
                Title = "le title",
                Phone = "8765435467",
                Email = "*****@*****.**",
                Address1 = "123 Foo",
                Address2 = "Suite 5",
                City = "Dallas",
                State = "TX",
                PostalCode = "76543",
                MissionStatement = "To hate Ken"
                
            };
            dataContext.BoardMembers.Add(member);
            dataContext.SaveChanges();

            //Get
            var dude = dataContext.BoardMembers.Find(member.BoardMemberId);
            Assert.IsNotNull(dude);

            //Update
            dude.LastName = "JustinIsShort";
            dataContext.SaveChanges();
            dude = dataContext.BoardMembers.Find(member.BoardMemberId);
            Assert.AreEqual("JustinIsShort", dude.LastName, "Bad last name.");

            //Delete
            dataContext.BoardMembers.Remove(dude);
            dataContext.SaveChanges();
            dude = dataContext.BoardMembers.Find(member.BoardMemberId);
            Assert.IsNull(dude, "Did not delete.");
        }