Ejemplo n.º 1
0
        public int EditUsers(List <Employee> ADUsers)
        {
            using (EmployeeDataEntities db = new EmployeeDataEntities())
            {
                var usernames = ADUsers.Select(t => t.Username).ToArray();
                var dbUsers   = db.Employees.Where(t => usernames.Contains(t.Username)).ToDictionary(t => t.Username);
                foreach (var aDUser in ADUsers)
                {
                    var preTebADUser = dbUsers[aDUser.Username];
                    userDict.Remove(aDUser.Username);
                    alluserDict.Remove(aDUser.Username);

                    preTebADUser.Initials            = string.IsNullOrWhiteSpace(aDUser.Initials) ? preTebADUser.Initials : aDUser.Initials;
                    preTebADUser.DisplayName         = aDUser.DisplayName;
                    preTebADUser.CompanyMail         = aDUser.CompanyMail;
                    preTebADUser.CompanyMail2        = aDUser.CompanyMail2;
                    preTebADUser.TelephoneNumber     = aDUser.TelephoneNumber;
                    preTebADUser.DisplayPicture      = aDUser.DisplayPicture;
                    preTebADUser.ElectronicSignature = aDUser.ElectronicSignature;
                    preTebADUser.OfficialDepartment  = aDUser.OfficialDepartment;
                    preTebADUser.DepartmentOverride  = aDUser.DepartmentOverride;
                    preTebADUser.JobTitle            = aDUser.JobTitle;
                    preTebADUser.Location            = aDUser.Location;
                    preTebADUser.UserStatus          = aDUser.UserStatus;

                    db.Entry(preTebADUser).State = EntityState.Modified;
                    AddToDictionary(preTebADUser);
                }
                return(db.SaveChanges());
            }
        }
Ejemplo n.º 2
0
        public int ChangeUserStatus(List <Employee> ADUsers, UserStatus status)
        {
            using (EmployeeDataEntities db = new EmployeeDataEntities())
            {
                foreach (var aDUser in ADUsers)
                {
                    var PreTebADUser = db.Employees.Where(t => t.Username == aDUser.Username).FirstOrDefault();
                    userDict.Remove(aDUser.Username);
                    alluserDict.Remove(aDUser.Username);
                    PreTebADUser.UserStatus = status;

                    db.Entry(PreTebADUser).State = EntityState.Modified;
                    AddToDictionary(PreTebADUser);
                }
                return(db.SaveChanges());
            }
        }