private void AddOrUpdatePromoterUser(EKontoUser eKontoUser)
        {
            var role         = _context.Roles.FirstOrDefault(r => r.Name == "Promoter");
            var existingUser = _context.Users.FirstOrDefault(u => u.Id == eKontoUser.id);

            if (existingUser == null)
            {
                var user = new User();
                user               = _mapper.Map(eKontoUser, user);
                user.Id            = eKontoUser.id;
                user.SecurityStamp = "";
                _context.Users.Add(user);
                _context.UserRoles.Add(new IntUserRole {
                    UserId = eKontoUser.id,
                    RoleId = role.Id
                });
            }
            else
            {
                var user = _mapper.Map(eKontoUser, existingUser);
                _context.Users.Update(user);
                var userRoles = _context.UserRoles.Where(r => r.UserId == eKontoUser.id);
                _context.UserRoles.RemoveRange(userRoles);
                _context.SaveChanges();
                _context.UserRoles.Add(new IntUserRole {
                    UserId = eKontoUser.id,
                    RoleId = role.Id
                });
            }
            _context.SaveChanges();
        }
Exemple #2
0
        private void DeleteObsoleteFacultyCourses(IEnumerable <Course> newCourses, int facultyId)
        {
            var obsoleteCourses = GetObsoleteFacultyCourses(newCourses, facultyId);

            _context.Courses.RemoveRange(obsoleteCourses);
            _context.SaveChanges();
        }
Exemple #3
0
        public void Synchronize()
        {
            var roles = new IntRole[] {
                new IntRole()
                {
                    Id             = 0,
                    Name           = "Promoter",
                    NormalizedName = "Promoter"
                },
                new IntRole()
                {
                    Id             = 1,
                    Name           = "Dean",
                    NormalizedName = "Dean"
                },
                new IntRole()
                {
                    Id             = 2,
                    Name           = "Admin",
                    NormalizedName = "Admin"
                }
            };

            AddOrUpdateRange(roles);
            _context.SaveChanges();
        }
        public void Synchronize()
        {
            var user = CreateAdminAccount();

            AddOrUpdate(user);
            _context.SaveChanges();
        }
Exemple #5
0
        public void Synchronize()
        {
            var instituteDepartments = getInstituteDepartments();

            foreach (var instituteDepartment in instituteDepartments)
            {
                var institute = _mapper.Map <Institute>(instituteDepartment);
                AddOrUpdate(institute);
            }
            _context.SaveChanges();
        }
Exemple #6
0
        public void Synchronize()
        {
            var eDziekanatFaculties = _eDziekanatClient.GetFaculties(true);

            foreach (var eDziekanatFaculty in eDziekanatFaculties)
            {
                if (eDziekanatFaculty.id == DoctoralSchool)
                {
                    continue;
                }
                var faculty = _mapper.Map <Faculty>(eDziekanatFaculty);
                AddOrUpdate(faculty);
            }
            _context.SaveChanges();
        }