public void RemoveAssociationStaffUser(int userId)
        {
            if (!Roles.IsUserInRole(RoleName.StaffManager))
                throw new SecurityException();

            using (var db = new LomsContext())
            {
                var user = new AssociationStaffUser() { Id = userId };
                db.AssociationStaffUsers.Attach(user);
                db.AssociationStaffUsers.DeleteObject(user);
                db.SaveChanges();
            }
        }
     public bool Equals(AssociationStaffUser 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;
     }
        public AssociationStaffUser SaveAssociationStaffUser(AssociationStaffUser user)
        {
            int staffManagerId = int.Parse(((FormsIdentity)(HttpContext.Current.User.Identity)).Ticket.UserData);
            if (!Roles.IsUserInRole(RoleName.StaffManager))
                if (Roles.IsUserInRole(RoleName.StaffUser) && staffManagerId != user.Id)
                    throw new SecurityException();

            using (var scope = new TransactionScope())
            using (var db = new LomsContext())
            {
                //AssociationStaffUser staffUser = null;
                //if (user.Id != 0)
                //    staffUser = db.AssociationStaffUsers.FirstOrDefault(u => u.Id == user.Id);

                user.AssociationId = CurrentAssociationId;
                if (user.Id == 0)
                {
                    user.Login = user.FirstName[0] + user.LastName;

                    var staffManager = (from m in db.AssociationStaffUsers
                                        where m.Id == staffManagerId
                                        select m).Single();

                    user.CreatedBy = staffManager.FirstName + " " + staffManager.LastName;
                    user.CreatedDate = DateTime.UtcNow;
                }

                if (user.Id == 0)
                {
                    if (user.Id == 0 && string.IsNullOrEmpty(user.Pwd))
                        user.Pwd = "123456!";

                    MembershipCreateStatus ret;
                    MembershipUser membershipUser = Membership.CreateUser(user.Login, user.Pwd, user.Email, "Who am I?", "I", true, null, out ret);
                    if (ret != MembershipCreateStatus.Success)
                        throw new ApplicationException(ret.ToString());


                    user.AspNetUserId = (Guid)membershipUser.ProviderUserKey;
                }
                else if (!string.IsNullOrEmpty(user.Pwd))
                {
                    MembershipUser membershipUser = Membership.GetUser(user.Login);
                    string tempPwd = membershipUser.ResetPassword();
                    membershipUser.ChangePassword(tempPwd, user.Pwd);
                }

                if (!Roles.IsUserInRole(user.Login, RoleName.StaffUser))
                    Roles.AddUserToRole(user.Login, RoleName.StaffUser);

                if (user.Role == AssociationStaffUserRole.Manager && !Roles.IsUserInRole(user.Login, RoleName.StaffManager))
                    Roles.AddUserToRole(user.Login, RoleName.StaffManager);
                else if (user.Role != AssociationStaffUserRole.Manager && Roles.IsUserInRole(user.Login, RoleName.StaffManager))
                    Roles.RemoveUserFromRole(user.Login, RoleName.StaffManager);

                if (user.Suburb != null)
                {
                    user.Country = null;
                    user.State = null;
                }
                else if (user.State != null)
                    user.Country = null;

                db.AssociationStaffUsers.ApplyChanges(user);
                db.SaveChanges();

                user = db.AssociationStaffUsers.IncludeAll("Country", "State", "State.Country", "Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country")
                    .FirstOrDefault(a => a.Id == user.Id);

                scope.Complete();

                return user;
            }
        }