public int CreateNewAuthority(Authority authority)
        {
            using (DobbermanEntities context = new DobbermanEntities())
            {
                // find out if authority already exists by its name
                AuthorityEntity validateAuthority = (from p
                                             in context.Authorities
                                           where p.Name == authority.Name
                                           select p).FirstOrDefault();
                if (!(validateAuthority == null)) return validateAuthority.AuthorityId;

                AuthorityEntity authorityEntity = new AuthorityEntity()
                {
                    Name = authority.Name,
                    CategoryId = authority.CategoryId,
                    FacebookPage = authority.FacebookPage,
                    AccumulatedScore = 0,
                    Score = 50,

                };
                context.AddToAuthorities(authorityEntity);
                context.SaveChanges();
                return authorityEntity.AuthorityId;
            }
        }
 private Authority TranslateAuthorityEntityToAuthority(AuthorityEntity authorityEntity)
 {
     Authority authority = new Authority()
     {
         AuthorityId = authorityEntity.AuthorityId,
         Name = authorityEntity.Name,
         FacebookPage = authorityEntity.FacebookPage,
         Score = authorityEntity.Score,
         Logo = authorityEntity.Logo,
         CategoryId = authorityEntity.CategoryId,
         Category = TranslateCategoryEntityToCategory(authorityEntity.Category),
     };
     return authority;
 }