public static void CreateUser(UserProfile user)
 {
     UserProfile dbUser = GetUser(user.UserName);
     if (dbUser != null)
         throw new Exception("User with that username already exists.");
     UnitOfWork uow = new UnitOfWork();
     uow.UserProfileRepository.Insert(user);
     uow.Save();
 }
 public static UserProfile GetUser(string username)
 {
     UnitOfWork uow = new UnitOfWork();
     return uow.UserProfileRepository.Get(u => u.UserName == username).SingleOrDefault();
 }