public void RemoveEmail(AssociationBillingAccountUser user)
 {
     if (user != null)
     {
         BillingAccount.Users.Remove(user);
     }
 }
        public SaveAssociationBillingAccountUsersResponse SaveBillingAccountUsers(SaveAssociationBillingAccountUsersRequest request)
        {
            var response = new SaveAssociationBillingAccountUsersResponse();

            using (var db = new LomsContext())
            {
                if (request.NewUserEmails != null)
                    foreach (var email in request.NewUserEmails)
                    {
                        var user = (from u in db.AssociationUsers
                                    where u.AssociationId == CurrentAssociationId && u.Email == email
                                    select u)
                                .SingleOrDefault();

                        if (user == null || !user.HasOnlineAccess)
                            response.EmailErrors[email] = "User is not registered!";
                        else if (response.EmailErrors.Count == 0)
                        {
                            var billingAccountUser = new AssociationBillingAccountUser()
                            {
                                BillingAccountId = request.BillingAccountId,
                                UserId = user.Id
                            };
                            db.AssociationBillingAccountUsers.ApplyChanges(billingAccountUser);
                        }
                    }

                if (response.EmailErrors.Count == 0)
                {
                    if (request.RemovedUserIds != null)
                        foreach (var billingAccountUserId in request.RemovedUserIds)
                        {
                            var user = new AssociationBillingAccountUser() { Id = billingAccountUserId };
                            db.AssociationBillingAccountUsers.Attach(user);
                            db.AssociationBillingAccountUsers.DeleteObject(user);
                        }

                    db.SaveChanges();

                    response.BillingAccount = (from cb in db.AssociationBillingAccounts.IncludeAll("Country", "Users", "Users.User")
                                               where cb.Id == request.BillingAccountId
                                           select cb).Single();
                }

                return response;
            }
        }
     public bool Equals(AssociationBillingAccountUser other)
     {
         if (ReferenceEquals(null, other)) return false;
         if (ReferenceEquals(this, other)) return true;
 		if (other.Id == 0 && Id == 0)
 			return false;
 		else
 			return other.Id == Id;
     }