Exemplo n.º 1
0
        public static ApplicationUser CreateUser(UserManager<ApplicationUser> userManager, string email, string firstName, string lastName,
           string password, bool lockOutEnabled)
        {
            var user = userManager.FindByName(email);

            if (user == null)
            {
                user = new ApplicationUser
                {
                    UserName = email,
                    Email = email,
                    FirstName = firstName,
                    LastName = lastName,
                    EmailConfirmed = true
                };
                try
                {
                    userManager.Create(user, password);
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Log("Error creating Admin User", LogLevel.ERROR, "AspNetUser", 1, "none", ex);
                }
                userManager.SetLockoutEnabled(user.Id, lockOutEnabled);
            }
            return user;
        }
Exemplo n.º 2
0
        public async Task<ActionResult> DisableUser(string userName)
        {

   
            List<string> users;
            List<string> enabledUsers;
            List<string> disabledUsers;
            using (var context = new ApplicationDbContext())
            {

                var userStore = new UserStore<ApplicationUser>(context);
                var userManager = new UserManager<ApplicationUser>(userStore);

                var selectedUser = userManager.FindByName(userName);

                if (selectedUser == null)
                    throw new Exception("User not found!");

                if (!selectedUser.UserName.Equals("*****@*****.**"))
                {


                    if (!selectedUser.LockoutEnabled)
                    {
                        userManager.SetLockoutEnabled(selectedUser.Id, true);
                        DateTime lockoutDate = DateTime.Now.AddYears(50);
                        await userManager.SetLockoutEndDateAsync(selectedUser.Id, lockoutDate);
                        context.SaveChanges();
                        userManager.Update(selectedUser);
                        ViewBag.ResultMessage = "Disabled successfully !";

                    }
                }
                else
                {
                    ViewBag.ResultMessage = "Cannot disable Admin";
                }

                users = (from u in userManager.Users select u.UserName).ToList();
                disabledUsers = new List<string>(users);
                enabledUsers = new List<string>(users);
                foreach (var user in users)
                {
                    if (!userManager.FindByName(user).LockoutEnabled)
                    {
                        disabledUsers.Remove(user);
                    }
                    else
                    {
                        enabledUsers.Remove(user);
                    }
                }
            }

            ViewBag.EnabledUsers = new SelectList(enabledUsers);
            ViewBag.DisabledUsers = new SelectList(disabledUsers);
            return View();
        }
Exemplo n.º 3
0
        private static void SetupRolesAndUsers(DbContext context)
        {
            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
            // add roles
            if (!roleManager.RoleExists(Role.Guest.ToString()))
                roleManager.Create(new IdentityRole(Role.Guest.ToString()));
            if (!roleManager.RoleExists(Role.Supplier.ToString()))
                roleManager.Create(new IdentityRole(Role.Supplier.ToString()));
            if (!roleManager.RoleExists(Role.Deactivated.ToString()))
                roleManager.Create(new IdentityRole(Role.Deactivated.ToString()));
            if (!roleManager.RoleExists(Role.User.ToString()))
                roleManager.Create(new IdentityRole(Role.User.ToString()));
            var adminRole = roleManager.FindByName(Role.Admin.ToString());
            if (adminRole == null)
            {
                adminRole = new IdentityRole(Role.Admin.ToString());
                roleManager.Create(adminRole);
            }
            #if DEBUG
            //add admin user
            var admin = userManager.Find(Admin_User, Admin_Pass);
            if (admin == null)
            {
                admin = new ApplicationUser
                {
                    UserName = Admin_User,
                    Email = Admin_Mail,
                    EmailConfirmed = true
                };
                var result = userManager.Create(admin, Admin_Pass);
                // TODO: verify returned IdentityResult
                userManager.AddToRole(admin.Id, Role.Admin.ToString());
                result = userManager.SetLockoutEnabled(admin.Id, false);
            }

            var rolesForUser = userManager.GetRoles(admin.Id);
            if (!rolesForUser.Contains(adminRole.Name))
            {
                var result = userManager.AddToRole(admin.Id, adminRole.Name);
            }

            //add normal user
            if (userManager.Find("*****@*****.**", "1q2w3e4r") == null)
            {
                var user = new ApplicationUser
                {
                    UserName = "******",
                    Email = "*****@*****.**",
                    EmailConfirmed = true
                };
                userManager.Create(user, "1q2w3e4r");
                // TODO: verify returned IdentityResult
                userManager.AddToRole(user.Id, Role.User.ToString());
            }
            #endif
        }
Exemplo n.º 4
0
        public ActionResult EditUser(UserViewModel model)
        {
            model.AppUser.UserName = model.AppUser.Email;
            var userMgr = new UserManager <AppUser>(new UserStore <AppUser>(context));
            var roleMgr = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var user    = userMgr.FindById(model.AppUser.Id);

            if (userMgr.FindById(model.AppUser.Id) != null)
            {
                user.FirstName = model.AppUser.FirstName;
                user.LastName  = model.AppUser.LastName;
                user.Email     = model.AppUser.Email;
                user.UserName  = model.AppUser.Email;
                userMgr.Update(user);
                if (!string.IsNullOrWhiteSpace(model.NewPassword) && !string.IsNullOrWhiteSpace(model.ConfirmPassword))
                {
                    if (ModelState.IsValid)
                    {
                        user.PasswordHash = userMgr.PasswordHasher.HashPassword(model.ConfirmPassword);
                    }
                }
            }
            var role = context.Roles.SingleOrDefault(r => r.Id == model.RoleId);

            string[] allUserRoles = userMgr.GetRoles(user.Id).ToArray();
            userMgr.RemoveFromRoles(user.Id, allUserRoles);
            userMgr.AddToRole(user.Id, role.Name);
            if (role.Name == "disabled")
            {
                userMgr.SetLockoutEnabled(user.Id, true);
                userMgr.Update(user);
            }
            if (role.Name == "sales" || role.Name == "admin")
            {
                userMgr.SetLockoutEnabled(user.Id, false);
                userMgr.Update(user);
            }
            context.SaveChanges();
            return(RedirectToAction("Users"));
        }
Exemplo n.º 5
0
        protected override void Seed(IdentitySample.Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            var          userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var          roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            const string name        = "*****@*****.**";

            const string password = "******";
            const string roleName = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new IdentityRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser {
                    UserName = name, Email = name
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(user.Id);

            if (!rolesForUser.Contains(role.Name))
            {
                var result = userManager.AddToRole(user.Id, role.Name);
            }

            //context.Users.AddOrUpdate(p => p.Id, new ApplicationUser{ Email = "*****@*****.**", UserName = "******", PasswordHash="nomina" });
        }
Exemplo n.º 6
0
 private void CreateAdmin()
 {
     if (userManager.FindByEmail("*****@*****.**") == null)
     {
         var user = new ApplicationUser();
         user.Email    = "*****@*****.**";
         user.UserName = "******";
         string password = "******";
         userManager.Create(user, password);
         userManager.SetLockoutEnabled(user.Id, false);
         userManager.AddToRole(user.Id, "Admin");
     }
 }
        public ActionResult UnBlockUserAccount(UserBlockData userBlockData)
        {
            var result = UserManager.SetLockoutEnabled(userBlockData.UserId, true);

            if (result.Succeeded)
            {
                result = UserManager.SetLockoutEndDate(userBlockData.UserId, DateTimeOffset.UtcNow);
                result = UserManager.SetLockoutEnabled(userBlockData.UserId, false);
                ApplicationUser applicationUser = UserManager.FindById(userBlockData.UserId);
                logger.Info($"Был разблокирован пользователь, у которого логин {applicationUser.UserName} и почта {applicationUser.Email}");
            }
            return(RedirectToAction("DataUsers"));
        }
Exemplo n.º 8
0
 public ActionResult UnlockUser(FormCollection formCollection)
 {
     if (formCollection["UserId"] != null)
     {
         string[] selectedUsers = formCollection["UserId"].Split(new char[] { ',' });
         foreach (string id in selectedUsers)
         {
             var user = UserManager.Users.SingleOrDefault(x => x.Id == id);
             UserManager.SetLockoutEnabled(user.Id, true);
         }
     }
     return(RedirectToAction("ShowAllUsers"));
 }
Exemplo n.º 9
0
        public static void InitializeIdentityForEF(ApplicationDbContext db)
        {
            //var userManager = HttpContext.Current
            //    .GetOwinContext().GetUserManager<ApplicationUserManager>();
            //var roleManager = HttpContext.Current
            //    .GetOwinContext().Get<ApplicationRoleManager>();

            var roleStore   = new RoleStore <ApplicationRole, string, ApplicationUserRole>(db);
            var roleManager = new RoleManager <ApplicationRole, string>(roleStore);
            var userStore   = new UserStore <ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>(db);
            var userManager = new UserManager <ApplicationUser, string>(userStore);


            const string name     = "*****@*****.**";
            const string email    = "*****@*****.**";
            const string password = "******";
            const string roleName = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new ApplicationRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser
                {
                    UserName       = name,
                    FirstName      = "Admin",
                    LastName       = "WorkCard.vn",
                    Email          = email,
                    EmailConfirmed = true
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
                userManager.AddToRole(user.Id, roleName);
            }

            var groupManager = new ApplicationGroupManager();
            var newGroup     = new ApplicationGroup("SuperAdmins", "Full Access to All");

            groupManager.CreateGroup(newGroup);
            groupManager.SetUserGroups(user.Id, new string[] { newGroup.Id });
            groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });
        }
Exemplo n.º 10
0
        public static void SeedAdminUser(ApplicationDbContext db)
        {
            var          userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            var          roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(db));
            const string name        = "*****@*****.**";
            const string password    = "******";
            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(SysWaterRevRoles.Administrators);

            if (role == null)
            {
                role = new ApplicationRole(SysWaterRevRoles.Administrators);
                var roleresult = roleManager.Create(role);
            }
            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser
                {
                    UserName        = name,
                    Email           = name,
                    PhoneNumber     = "+254710773556",
                    IsActive        = true,
                    EmployeeDetails = new Employee
                    {
                        CreatedBy      = "Auto",
                        DateCreated    = DateTime.Now,
                        EmailAddress   = name,
                        EmployeeGender = Gender.Male,
                        EmployeeNumber = "ADMIN123",
                        FirstName      = "George",
                        Identification = "28350053",
                        Surname        = "Ndungu",
                        MiddleName     = "Mbuthia",
                        PhoneNumber    = "+254710773556",
                        EmployeeId     = IdentityGenerator.NewSequentialGuid()
                    }
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }
            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(user.Id);

            if (!rolesForUser.Contains(role.Name))
            {
                var result = userManager.AddToRole(user.Id, SysWaterRevRoles.Administrators);
            }
        }
Exemplo n.º 11
0
        public ActionResult Create(WebUserFormViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = UserManager.FindByEmail(model.Email);
                    if (user == null)
                    {
                        user = new ApplicationUser {
                            UserName = model.Email, Email = model.Email
                        };
                        var result = UserManager.Create(user, model.Password);
                        result = UserManager.SetLockoutEnabled(user.Id, false);

                        if (result.Succeeded)
                        {
                            model.AccountId = user.Id;
                            // User cannot to have admin role
                        }
                    }
                    else
                    {
                        model.AccountId = user.Id;
                    }

                    ServiceUser.Add(new WebUserDto()
                    {
                        Name         = model.Name,
                        LastName     = model.LastName,
                        Email        = model.Email,
                        AccountId    = model.AccountId, //Update from Identity
                        RegisterDate = DateTime.Now,
                        Active       = model.Active
                    });
                }
                else
                {
                    ModelState.AddModelError("Error", "Algunos datos ingresados no son válidos");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", "Se ha producido un error: " + ex.Message);
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 12
0
        public static bool InitializeIdentityForEF(BlogDbContext db)
        {
            /*var userManager = HttpContext.Current.GetOwinContext().GetUserManager<UserManager>();
            *  var roleManager = HttpContext.Current.GetOwinContext().Get<ApplicationRoleManager>();*/
            var roleStore   = new RoleStore <IdentityRole>(db);
            var roleManager = new RoleManager <IdentityRole>(roleStore);
            var userStore   = new UserStore <User>(db);
            var userManager = new UserManager <User>(userStore);

            const string name     = "*****@*****.**";
            const string password = "******";
            const string roleName = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new IdentityRole(roleName);
                var roleresult = roleManager.Create(role);
            }
            else
            {
                return(false);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new User {
                    UserName = name, Email = name
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }
            else
            {
                return(false);
            }

            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(user.Id);

            if (!rolesForUser.Contains(role.Name))
            {
                var result = userManager.AddToRole(user.Id, role.Name);
            }
            return(true);
        }
Exemplo n.º 13
0
        public void CanSetLockoutTime()
        {
            DateTime lockoutTime = DateTime.UtcNow.AddDays(1);
            var      user        = CreateBasicUser();

            UserManager.SetLockoutEnabled(user.Id, true);

            var result = UserManager.SetLockoutEndDate(user.Id, lockoutTime);

            var newUser = UserManager.FindById(user.Id);

            result.Succeeded.ShouldBe(true);
            newUser.LockedOutUntilUtc.ShouldNotBe(null);
        }
Exemplo n.º 14
0
        public IHttpActionResult PutArchiveUser(string id)
        {
            var user = UserManager.FindById(id);

            if (user == null)
            {
                return(NotFound());
            }

            UserManager.SetLockoutEnabled(user.Id, true);
            UserManager.SetLockoutEndDate(user.Id, DateTime.MaxValue);

            return(Ok());
        }
        // GET: Setup
        public ActionResult DefaultUsers()
        {
            var user = UserManager.FindByName(AppConstants.DefaultUserName);

            if (user == null)
            {
                user = new ApplicationUser
                {
                    UserName             = AppConstants.DefaultUserName,
                    Email                = AppConstants.DefaultUserEmail,
                    EmailConfirmed       = true,
                    PhoneNumber          = AppConstants.MobilePhone,
                    PhoneNumberConfirmed = true
                };
                var result = UserManager.Create(user, AppConstants.DefaultPass);
                result = UserManager.SetLockoutEnabled(user.Id, false);
            }

            var adminRole = RoleManager.FindByName(AppConstants.AdminRoleName);

            if (adminRole == null)
            {
                adminRole = new ApplicationRole(AppConstants.AdminRoleName);
                var roleresult = RoleManager.Create(adminRole);
            }

            var group = GroupManager.FindByName(AppConstants.SuperAdminsGroup);

            if (group == null)
            {
                group = new ApplicationGroup(AppConstants.SuperAdminsGroup, "Full Access to All");
                GroupManager.CreateGroup(group);
            }

            var userBlongToGroup = GroupManager.IsUserBlongToGroup(user.Id, group.Id);

            if (userBlongToGroup == false)
            {
                GroupManager.SetUserGroups(user.Id, new string[] { group.Id });
            }

            var groupHaveRole = GroupManager.IsGroupHasRole(group.Id, adminRole.Id);

            if (groupHaveRole == false)
            {
                GroupManager.SetGroupRoles(group.Id, new string[] { adminRole.Id });
            }
            return(Content("default Users , Groups  and Roles Creation success"));
        }
        public String AddAdmin()
        {
            const string name     = "*****@*****.**";
            const string password = "******";
            const string roleName = "Admin";

            //Create Role Admin if it does not exist
            var role = RoleManager.FindByName(roleName);

            if (role == null)
            {
                role = new IdentityRole(roleName);
                var roleresult = RoleManager.Create(role);
            }

            var user = UserManager.FindByName(name);

            if (user == null)
            {
                user = new AppUser {
                    UserName = name, Email = name
                };
                var result = UserManager.Create(user, password);
                result = UserManager.SetLockoutEnabled(user.Id, false);


                // Add user admin to Role Admin if not already added
                var rolesForUser = UserManager.GetRoles(user.Id);
                if (!rolesForUser.Contains(role.Name))
                {
                    var resultRole = UserManager.AddToRole(user.Id, role.Name);
                }

                user.EmailConfirmed = true;
                UserManager.Update(user);

                var myUser = new MyUser
                {
                    AppUserId   = user.Id,
                    DateCreated = DateTime.Now,
                    DisplayName = user.Email,
                    Email       = user.Email,
                    IsActive    = true
                };
                _userRepository.Create(myUser);
            }

            return("Admin CREATED SUCCESSFULY");
        }
Exemplo n.º 17
0
        public static void DefaultUser(ApplicationDbContext db)
        {

            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(db));

            var name = AppConfig.DefaultUser;
            var pwd = AppConfig.DefaultUserPassword;
            const string adminRole = "Admin";
            const string dashboardRole = "Dashboard";
            const string investigateRole = "Investigate";

            //Create Role Admin if it does not exist
            var ar = roleManager.FindByName(adminRole);
            if (ar == null)
            {
                ar = new IdentityRole(adminRole);
                var roleresult = roleManager.Create(ar);
            }

            var dr = roleManager.FindByName(dashboardRole);
            if (dr == null)
            {
                dr = new IdentityRole(dashboardRole);
                var roleresult = roleManager.Create(dr);
            }

            var ir = roleManager.FindByName(investigateRole);
            if (ir == null)
            {
                ir = new IdentityRole(investigateRole);
                var roleresult = roleManager.Create(ir);
            }

            var user = userManager.FindByName(name);
            if (user == null)
            {
                user = new ApplicationUser { UserName = name, Email = name, EmailConfirmed = true };
                var createUser = userManager.Create(user, pwd);
                createUser = userManager.SetLockoutEnabled(user.Id, false);
            }

            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(user.Id);
            if (!rolesForUser.Contains("Admin"))
            {
                var result = userManager.AddToRole(user.Id, "Admin");
            }
        }
 public ActionResult BlockUserAccount(UserBlockData userBlockData)
 {
     if (ModelState.IsValid)
     {
         var result = UserManager.SetLockoutEnabled(userBlockData.UserId, true);
         if (result.Succeeded)
         {
             result = UserManager.SetLockoutEndDate(userBlockData.UserId, (DateTimeOffset)userBlockData.DateTimeBlock);
             ApplicationUser applicationUser = UserManager.FindById(userBlockData.UserId);
             logger.Info($"Был заблокирован пользователь, у которого логин {applicationUser.UserName} и почта {applicationUser.Email}");
         }
         return(RedirectToAction("DataUsers"));
     }
     return(View());
 }
Exemplo n.º 19
0
        void CreateUser(string userName, string password, string roleName, UserManager <ApplicationUser> userManager)
        {
            var user = userManager.FindByName(userName);

            if (user == null)
            {
                var newUser = new ApplicationUser()
                {
                    UserName = userName
                };
                userManager.Create(newUser, password);
                userManager.SetLockoutEnabled(newUser.Id, false);
                userManager.AddToRole(newUser.Id, roleName);
            }
        }
Exemplo n.º 20
0
        public static void InitializeIdentityForEF(StoreContext db)
        {
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(db));

            //var userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
            //var roleManager = HttpContext.Current.GetOwinContext().Get<ApplicationRoleManager>();
            const string name     = "*****@*****.**";
            const string password = "******";
            const string roleName = "Admin";


            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser {
                    UserName = name, Email = name, UserData = new UserData()
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new IdentityRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            //var user = userManager.FindByName(name);
            //if (user == null)
            //{
            //    user = new ApplicationUser { UserName = name, Email = name };
            //    var result = userManager.Create(user, password);
            //    result = userManager.SetLockoutEnabled(user.Id, false);
            //}

            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(user.Id);

            if (!rolesForUser.Contains(role.Name))
            {
                var result = userManager.AddToRole(user.Id, role.Name);
            }
        }
Exemplo n.º 21
0
        public void CanUnlockAccount()
        {
            DateTime lockoutTime = DateTime.UtcNow.AddDays(1);
            var      user        = CreateBasicUser();

            var result = UserManager.SetLockoutEnabled(user.Id, true);

            result.Succeeded.ShouldBe(true);

            var unlockResult = UserManager.SetLockoutEnabled(user.Id, false);

            var newUser = UserManager.FindById(user.Id);

            unlockResult.Succeeded.ShouldBe(true);
            newUser.LockedOut.ShouldBe(false);
        }
Exemplo n.º 22
0
        private void CreateAdmin()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            if (userManager.FindByEmail("*****@*****.**") == null)
            {
                var user = new ApplicationUser();
                user.Email    = "*****@*****.**";
                user.UserName = "******";
                string password = "******";
                userManager.Create(user, password);
                userManager.SetLockoutEnabled(user.Id, false);
                userManager.AddToRoleAsync(user.Id, "Admin");
            }
        }
        protected override void Seed(ProjectDbContext context)
        {
            // init users and roles manager
            var userManager = new UserManager <ProjectUser, Guid>(new ProjectUserStore(context));
            var roleManager = new RoleManager <ProjectRole, Guid>(new ProjectRoleStore(context));

            // system roles list
            var roles = typeof(RoleName).GetFields(BindingFlags.Static | BindingFlags.Public).Select(fi => fi.Name).ToList();

            // generate all system roles
            roles.ForEach(roleName => {
                //Create Role if it does not exist
                if (!roleManager.RoleExists(roleName))
                {
                    roleManager.Create(new ProjectRole(roleName));
                }
            });

            //system SuperAdmin
            var admin = new ProjectUser()
            {
                Id        = new Guid("1ABB568A-2ECD-43E6-B814-BE164CF2F6F4"),
                Email     = "*****@*****.**",
                UserName  = "******",
                FirstName = "SuperAdminFirstName",
                LastName  = "SuperAdminLastName"
            };
            var adminPassword = "******";

            //Create system SuperAdmin if notExist
            if (userManager.FindByName(admin.UserName) == null)
            {
                userManager.Create(admin, adminPassword);
                userManager.SetLockoutEnabled(admin.Id, false);
            }

            // Add SuperAdmin to role if not already added
            var adminRole    = RoleName.SuperAdmin;
            var rolesForUser = userManager.GetRoles(admin.Id);

            if (!rolesForUser.Contains(adminRole))
            {
                userManager.AddToRole(admin.Id, adminRole);
            }

            base.Seed(context);
        }
Exemplo n.º 24
0
        private void InitializeIdentity()
        {
            if (!this.Users.Any())
            {
                var roleStore   = new RoleStore <IdentityRole>(this);
                var roleManager = new RoleManager <IdentityRole>(roleStore);
                var userStore   = new UserStore <User>(this);
                var userManager = new UserManager <User>(userStore);

                var userRole = roleManager.FindByName("User");

                if (userRole == null)
                {
                    userRole = new IdentityRole("User");
                    roleManager.Create(userRole);
                }

                // Add missing roles
                var role = roleManager.FindByName("Admin");
                if (role == null)
                {
                    role = new IdentityRole("Admin");
                    roleManager.Create(role);
                }

                // Create test users
                var user = userManager.FindByName("admin");
                if (user == null)
                {
                    var newUser = new User()
                    {
                        UserName    = "******",
                        FirstName   = "Admin",
                        LastName    = "User",
                        Email       = "*****@*****.**",
                        PhoneNumber = "123456",
                        ImagePath   = "/Photos/Users/default-profile.png"
                    };

                    userManager.Create(newUser, "unicorn");
                    userManager.SetLockoutEnabled(newUser.Id, false);
                    userManager.AddToRole(newUser.Id, "Admin");

                    this.SaveChanges();
                }
            }
        }
Exemplo n.º 25
0
        public async Task <JsonResult> Register(RegisterViewModel model)
        {
            var roleManager = HttpContext.GetOwinContext().Get <ApplicationRoleManager>();

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email, DisplayName = model.DisplayName
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    //await UserManager.SendEmailAsync(user.Id, "Kích hoạt tài khoản", "Để kích hoạt tài khoản,vui lòng bấm vào đường dẫn <a href=\"" + callbackUrl + "\">link</a>");

                    user.Type     = 2;
                    user.UnitId   = SysBaseInfor.GetCurrentUnitId().ToInt32();
                    user.UnitName = SysBaseInfor.GetCurrentUnitCode().ToLower();
                    var resultActive = UserManager.SetLockoutEnabled(user.Id, false);
                    if (resultActive.Succeeded)
                    {
                        var roleForUserName = user.UserName + "_" + SysBaseInfor.GetCurrentUnitCode().ToLower() + SysBaseInfor.SignProject;
                        var roleForUser     = roleManager.FindByName(roleForUserName);
                        if (roleForUser == null)
                        {
                            roleForUser          = new ApplicationRole(roleForUserName);
                            roleForUser.RoleType = 3;
                            roleForUser.UnitId   = SysBaseInfor.GetCurrentUnitId().ToInt32();
                            var roleResult = roleManager.Create(roleForUser);
                            if (roleResult.Succeeded)
                            {
                                UserManager.AddToRole(user.Id, roleForUserName);
                                return(Json("Success"));
                            }
                        }
                    }
                    else
                    {
                        return(Json(resultActive.Errors.FirstOrDefault()));
                    }
                }
                return(Json(result.Errors.FirstOrDefault()));
            }
            return(Json("Không thể tạo người dùng"));
        }
Exemplo n.º 26
0
        private bool Create(string username, string displayname, string password, string roleId)
        {
            var roleManager = HttpContext.GetOwinContext().Get <ApplicationRoleManager>();

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName    = username,
                    DisplayName = displayname
                };
                var result = UserManager.Create(user, password);
                if (result.Succeeded)
                {
                    user.Type     = 2;
                    user.UnitId   = SysBaseInfor.GetCurrentUnitId().ToInt32();
                    user.UnitName = SysBaseInfor.GetCurrentUnitCode().ToLower();
                    try { user.TypeInfo = int.Parse(DBLibs.ExecuteScalar($"SELECT TOP 1 id FROM GiaoVien WHERE magv = N'{username.Replace("'", "''")}'", _cnn).ToString()); }
                    catch { }
                    var resultActive = UserManager.SetLockoutEnabled(user.Id, false);
                    if (resultActive.Succeeded)
                    {
                        try
                        {
                            var sql = $@"
                            INSERT INTO dbo.AspNetUserRoles
                            ( UserId, RoleId )
                            VALUES
                            (
	                            N'{user.Id}', -- UserId - nvarchar(128)
	                            N'{roleId}'  -- RoleId - nvarchar(128)
                            )";
                            DBLibs.ExecuteNonQuery(sql, _cnn);
                        }
                        catch { }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(false);
            }
            return(false);
        }
        public ActionResult RegisterOnRace(Models.RaceRegistration.RegisterOnRaceViewModel model)
        {
            ApplicationUser au;

            if (model.RegistrationTypeId == 1)
            {
                au = UserManager.Find(model.EmailLogin, model.PasswordLogin);
            }
            else
            {
                au = new ApplicationUser
                {
                    Email     = model.Email,
                    EGenderId = model.EGenderId,
                    BirthDate = Convert.ToDateTime(model.BirthDate),
                    FirstName = model.FirstName,
                    LastName  = model.SurName
                };

                if (model.CreateAccount)
                {
                    au.UserName = model.Email;
                    UserManager.Create(au, model.Password);
                    UserManager.SetLockoutEnabled(au.Id, false);
                    UserManager.AddToRole(au.Id, "User");
                }
                else
                {
                    au.UserName = Guid.NewGuid().ToString();
                    ApplicationUserRepository.Create(au, false);
                }
            }

            if (au != null)
            {
                Data.Models.RaceCategoryUser raceCategoryUser = new Data.Models.RaceCategoryUser()
                {
                    ApplicationUserId = au.Id,
                    RaceCategoryId    = model.RaceCategoryId,
                    RaceSubCategoryId = model.RaceSubCategoryId
                };
                RaceCategoryUsersRepository.Create(raceCategoryUser, true);
            }

            return(Content("OK"));
        }
Exemplo n.º 28
0
        public static void init(SACAAEContext context)
        {
            var userManager = new UserManager<User>(new UserStore<User>(context));

            const string usernameAdmin = "amasis";
            const string emailAdmin = "*****@*****.**";
            const string nameAdmin = "Alejandro Masís";
            const string passAdmin = "sacapassword";
            //Admin
            var admin = userManager.FindByName(usernameAdmin);
            if (admin == null)
            {
                admin = new User { UserName = usernameAdmin, Email = emailAdmin, Name = nameAdmin };
                var result = userManager.Create(admin, passAdmin);
                result = userManager.SetLockoutEnabled(admin.Id, false);
            }
        }
Exemplo n.º 29
0
        public static void InitializeIdentityForEF(RecipeBuilder_Version_1.DAL.RecipeBuilder2Context db)
        {
            var userManager = new UserManager <Member>(
                new UserStore <Member>(db));

            var roleManager = new RoleManager <IdentityRole>(
                new RoleStore <IdentityRole>(db));

            userManager.UserValidator = new UserValidator <Member>(userManager)
            {
                AllowOnlyAlphanumericUserNames = false
            };
            const string userName = "******";
            const string password = "******";
            const string roleName = "Admin";

            //Create Role "Admin" if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new IdentityRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var member = userManager.FindByName(userName);

            if (member == null)
            {
                member = new Member {
                    UserName = userName, Email = userName, NickName = roleName, FirstName = roleName, LastName = roleName, DateJoined = DateTime.Parse("2000-01-01")
                };
                var result = userManager.Create(member, password);
                InitializeAuthenticationApplyAppCookie(userManager, member);
                result = userManager.SetLockoutEnabled(member.Id, false);
            }

            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(member.Id);

            if (!rolesForUser.Contains(role.Name))
            {
                var result = userManager.AddToRole(member.Id, role.Name);
            }
        }
Exemplo n.º 30
0
        private void InitializeIdentityForEf(ToplantiTakipContext context)
        {
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));

            const string adminName      = "admin";
            const string adminFirstName = "Eren";
            const string adminLastName  = "Tatar";
            const string adminEmail     = "*****@*****.**";
            const string adminPassword  = "******";
            const string adminRole      = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(adminRole);

            if (role == null)
            {
                role = new IdentityRole(adminRole);
                var roleResult = roleManager.Create(role);
            }

            //Create User account if it does not exist
            var user = userManager.FindByEmail(adminEmail);

            if (user == null)
            {
                user = new ApplicationUser
                {
                    UserName  = adminName,
                    FirstName = adminFirstName,
                    LastName  = adminLastName,
                    Email     = adminEmail,
                };
                var result = userManager.Create(user, adminPassword);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            // Add user admin to Role Admin if not already added
            var rolesForUser = userManager.GetRoles(user.Id);

            if (!rolesForUser.Contains(role.Name))
            {
                var result = userManager.AddToRole(user.Id, role.Name);
            }
        }
Exemplo n.º 31
0
 public ActionResult LockUser(FormCollection formCollection)
 {
     if (formCollection["UserId"] != null)
     {
         var      userid        = User.Identity.GetUserId();
         string[] selectedUsers = formCollection["UserId"].Split(new char[] { ',' });
         foreach (string id in selectedUsers)
         {
             var user = UserManager.Users.SingleOrDefault(x => x.Id == id);
             if (user == UserManager.Users.SingleOrDefault(x => x.Id == userid))
             {
                 AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
             }
             UserManager.SetLockoutEnabled(user.Id, false);
         }
     }
     return(RedirectToAction("ShowAllUsers"));
 }
Exemplo n.º 32
0
        public IHttpActionResult LockAccount(string email)
        {
            try
            {
                var user = UserManager.FindByEmail(email);
                if (user != null)
                {
                    UserManager.SetLockoutEnabled(user.Id, true);
                    return(Ok("Success"));
                }

                throw new SystemException("User Status Not Change");
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 33
0
        private void CreateContentCreator()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var userManager =
                new UserManager <ApplicationUser>(
                    new UserStore <ApplicationUser>(context));

            if (userManager.FindByName("ContentCreator") == null)
            {
                var user = new ApplicationUser();
                user.Email    = "*****@*****.**";
                user.UserName = "******";
                string password = "******";
                userManager.Create(user, password);
                userManager.SetLockoutEnabled(user.Id, false);
                userManager.AddToRoleAsync(user.Id, "Creator");
            }
        }
Exemplo n.º 34
0
        internal static void DefaultUser(ApplicationDbContext ctx)
        {
            var userManager = new UserManager<User>(new UserStore<User>(ctx));
            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(ctx));

            var adminUser = AppConfig.DefaultAdminAccount;
            var adminPassword = AppConfig.DefaultAdminAccountPassword;
            const string roleName = "Admin";

            var role = roleManager.FindByName(roleName);
            if (role == null)
            {
                role = new IdentityRole(roleName);
                var createRoleResult = roleManager.Create(role);
            }

            var user = userManager.FindByName(adminUser);
            if (user == null)
            {
                user = new User
                {
                    UserName = adminUser,
                    Email = adminUser,
                    LockoutEnabled = false,
                    EmailConfirmed = true,
                    UserProfile = new UserProfile()
                    {
                        Title = "N/A",
                        Forename = "System",
                        Surname = "Administrator",
                        Alias = "Sysadmin",
                        JobTitle = "Administrator"
                    }
                };
                var createUserResult = userManager.Create(user, adminPassword);
                createUserResult = userManager.SetLockoutEnabled(user.Id, false);
            }

            var rolesForUser = userManager.GetRoles(user.Id);
            if (!rolesForUser.Contains(role.Name))
            {
                var addUserToRoleResult = userManager.AddToRole(user.Id, role.Name);
            }
        }
Exemplo n.º 35
0
        public ActionResult EnableUser(string userName)
        {
            List <string> users;
            List <string> enabledUsers;
            List <string> disabledUsers;

            using (var context = new ApplicationDbContext())
            {
                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new UserManager <ApplicationUser>(userStore);

                var selectedUser = userManager.FindByName(userName);
                if (selectedUser == null)
                {
                    throw new Exception("User not found!");
                }
                if (selectedUser.LockoutEnabled)
                {
                    userManager.SetLockoutEnabled(selectedUser.Id, false);
                    context.SaveChanges();
                    userManager.Update(selectedUser);
                }


                users         = (from u in userManager.Users select u.UserName).ToList();
                disabledUsers = new List <string>(users);
                enabledUsers  = new List <string>(users);
                foreach (var user in users)
                {
                    if (!userManager.FindByName(user).LockoutEnabled)
                    {
                        disabledUsers.Remove(user);
                    }
                    else
                    {
                        enabledUsers.Remove(user);
                    }
                }
            }
            ViewBag.ResultMessage = "Enabled successfully !";
            ViewBag.EnabledUsers  = new SelectList(enabledUsers);
            ViewBag.DisabledUsers = new SelectList(disabledUsers);
            return(View("DisableUser"));
        }
Exemplo n.º 36
0
        private bool InitializeAdmin(string role, List <string> errors)
        {
            bool succeeded = true;

            const string adminLogin = "******";
            const string password   = "******";

            ApplicationUser admin = userManager.FindByName(adminLogin);

            if (admin == null)
            {
                admin = new ApplicationUser
                {
                    UserName  = adminLogin,
                    FirstName = "John",
                    LastName  = "Black",
                    Email     = "*****@*****.**"
                };

                IdentityResult identityResult = userManager.Create(admin, password);
                if (identityResult.Succeeded)
                {
                    userManager.SetLockoutEnabled(admin.Id, false);
                }
                else
                {
                    succeeded = false;
                    errors.AddRange(identityResult.Errors);
                }
            }

            if (succeeded && !unitOfWork.Profiles.IsInRole(admin.Id, role))
            {
                IdentityResult identityResult = userManager.AddToRole(admin.Id, role);
                if (!identityResult.Succeeded)
                {
                    succeeded = false;
                    errors.AddRange(identityResult.Errors);
                }
            }

            return(succeeded);
        }
        public ActionResult Create([Bind(Include = "FirstName,LastName,Email,PhoneNumber,UserName")] ApplicationUser applicationUser)
        {
            if (ModelState.IsValid)
            {
                var userStore = new UserStore<ApplicationUser>(db);
                var userManager = new UserManager<ApplicationUser>(userStore);

                var user = userManager.FindByName(applicationUser.UserName);
                if (user == null)
                {
                    userManager.Create(applicationUser);
                    userManager.SetLockoutEnabled(applicationUser.Id, false);
                    userManager.AddToRoles(applicationUser.Id, Request["Role"]);

                    return RedirectToAction("Index");
                }
            }

            return View(applicationUser);
        }
Exemplo n.º 38
0
        public ActionResult EnableUser(string userName)
        {

            List<string> users;
            List<string> enabledUsers;
            List<string> disabledUsers;
            using (var context = new ApplicationDbContext())
            {

                var userStore = new UserStore<ApplicationUser>(context);
                var userManager = new UserManager<ApplicationUser>(userStore);

                var selectedUser = userManager.FindByName(userName);
                if (selectedUser == null)
                    throw new Exception("User not found!");
                if (selectedUser.LockoutEnabled)
                {
                    userManager.SetLockoutEnabled(selectedUser.Id, false);
                    context.SaveChanges();
                    userManager.Update(selectedUser);


                }


                users = (from u in userManager.Users select u.UserName).ToList();
                disabledUsers = new List<string>(users);
                enabledUsers = new List<string>(users);
                foreach (var user in users)
                {
                    if (!userManager.FindByName(user).LockoutEnabled)
                    {
                        disabledUsers.Remove(user);
                    }
                    else
                    {
                        enabledUsers.Remove(user);
                    }
                }
            }
            ViewBag.ResultMessage = "Enabled successfully !";
            ViewBag.EnabledUsers = new SelectList(enabledUsers);
            ViewBag.DisabledUsers = new SelectList(disabledUsers);
            return View("DisableUser");
        }
Exemplo n.º 39
0
        /// <summary>
        ///     Seed the Database with Courses, A default user, and roles
        ///     User and Role Seeding:
        ///     http://stackoverflow.com/questions/29526215/seed-entities-and-users-roles
        /// </summary>
        /// <param name="context">The context.</param>
        public static void Seed(Lab10DbContext context)
        {
            // If No users exist
            if (!context.Users.Any())
            {
                // Wire up Roles services
                var roleStore = new RoleStore<IdentityRole>(context);
                var roleManager = new RoleManager<IdentityRole>(roleStore);

                // Add Roles
                if (roleManager.FindByName(UserRoles.Coordinator) == null)
                    roleManager.Create(new IdentityRole(UserRoles.Coordinator));
                if (roleManager.FindByName(UserRoles.DepartmentChair) == null)
                    roleManager.Create(new IdentityRole(UserRoles.DepartmentChair));
                if (roleManager.FindByName(UserRoles.Instructor) == null)
                    roleManager.Create(new IdentityRole(UserRoles.Instructor));

                // Wire up user services
                var userStore = new UserStore<ApplicationUser>(context);
                var userManager = new UserManager<ApplicationUser>(userStore);

                // Set up the default password
                var password = "******";
                var hashedPassword = new PasswordHasher().HashPassword(password);

                if (userManager.FindByEmail("*****@*****.**") == null)
                {
                    var user = AddUser("WeiGong", "*****@*****.**", hashedPassword);
                    userManager.Create(user, password);
                    userManager.AddToRole(user.Id, UserRoles.Instructor);
                }

                if (userManager.FindByEmail("*****@*****.**") == null)
                {
                    var user = AddUser("JaneDoe", "*****@*****.**", hashedPassword);
                    userManager.Create(user, password);
                    userManager.AddToRole(user.Id, UserRoles.Instructor);
                }

                if (userManager.FindByEmail("*****@*****.**") == null)
                {
                    var user = AddUser("JohnSmith", "*****@*****.**", hashedPassword);
                    userManager.Create(user, password);
                    userManager.AddToRole(user.Id, UserRoles.Coordinator);
                }

                if (userManager.FindByEmail("*****@*****.**") == null)
                {
                    var user = AddUser("DavidJones", "*****@*****.**", hashedPassword);
                    userManager.Create(user, password);
                    userManager.AddToRole(user.Id, UserRoles.Coordinator);
                    userManager.AddToRole(user.Id, UserRoles.Instructor);
                }

                if (userManager.FindByEmail("*****@*****.**") == null)
                {
                    var user = AddUser("MaryRobinson", "*****@*****.**", hashedPassword);
                    userManager.Create(user, password);
                    userManager.SetLockoutEnabled(user.Id, false);
                    userManager.AddToRole(user.Id, UserRoles.DepartmentChair);
                }
            }

            // Seed the course Information
            context.Courses.AddOrUpdate(c => c.CourseNumber,
                new Course
                {
                    CourseNumber = "ICT0001",
                    CourseName = "Web Programming",
                    CourseDescription =
                        "Students learn how to manage their laptop environment to gain the best advantage during their college program and later in the workplace. Create backups, install virus protection, manage files through a basic understanding of the Windows Operating System, install and configure the Windows Operating System, install and manage a virtual machine environment. Explore computer architecture including the functional hardware and software components that are needed to run programs. Finally, study basic numerical systems and operations including Boolean logic.",
                    WeeklyHours = 4
                },
                new Course
                {
                    CourseNumber = "ICT0002",
                    CourseName = "Introduction to Computer Programming",
                    CourseDescription =
                        "Learn the fundamental problem-solving methodologies needed in software development, such as structured analysis, structured design, structured programming and introduction to object-oriented programming. Use pseudocode, flowcharting, as well as a programming language to develop solutions to real-world problems of increasing complexity. The basics of robust computer programming, with emphasis on correctness, structure, style and documentation are learned using Java. Theory is reinforced with application by means of practical laboratory assignments.",
                    WeeklyHours = 6
                },
                new Course
                {
                    CourseNumber = "ICT0003",
                    CourseName = "Web Programming I",
                    CourseDescription =
                        "Students learn to develop websites with XHTML, CSS and JavaScript which emphasize structured and modular programming with an object-based paradigm. The course reinforces theory with practical lab assignments to create websites and to explore web-based applications that include client-side script",
                    WeeklyHours = 4
                },
                new Course
                {
                    CourseNumber = "ICT0004",
                    CourseName = "Introduction to Database Systems",
                    CourseDescription =
                        "Students are introduced to the design and development of database systems using a current Database Management System (DBMS). Concepts and terminology of relational databases and design principles using the Entity Relationship model are presented. Students use SQL to create, modify and query a database. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 2
                },
                new Course
                {
                    CourseNumber = "ICT0005",
                    CourseName = "Achieving Success in Changing Environments",
                    CourseDescription =
                        "Rapid changes in technology have created personal and employment choices that challenge each of us to find our place as contributing citizens in the emerging society. Life in the 21st century presents significant opportunities, but it also creates potential hazards and ethical problems that demand responsible solutions. Students explore the possibilities ahead, assess their own aptitudes and strengths, and apply critical thinking and decision-making tools to help resolve some of the important issues in our complex society with its competing interests. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 4
                },
                new Course
                {
                    CourseNumber = "ICT0006",
                    CourseName = "Math Fundamentals",
                    CourseDescription =
                        "Students learn foundational mathematics required in many College technical programs. Students also solve measurement problems involving a variety of units and ratio and proportion problems. They manipulate algebraic expressions and solve equations. Students evaluate exponential and logarithmic expressions, study the trigonometry of right triangles and graph a variety of functions. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 4
                },
                new Course
                {
                    CourseNumber = "ICT0007",
                    CourseName = "Database Systems",
                    CourseDescription =
                        "Students acquire practical experience using Oracle, an object-relational database management system. Advanced topics in database design are covered. Students have hands-on use of SQL, SQL scripts, PL/SQL and embedded SQL in host programs. Database concepts covered include data storage and retrieval, administration data warehouse, data mining, decision support, business intelligence, security and transaction control. Students also explore the use of open source database software. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 6
                },
                new Course
                {
                    CourseNumber = "ICT0008",
                    CourseName = "Web Programming II",
                    CourseDescription =
                        "Through the study of C# and ASP.net, students learn the concepts of object-oriented programming as applied to the design, the development, and the debugging of ASP.net web. Object-oriented concepts, such as encapsulation, inheritance, abstraction and polymorphism are covered and reinforced with practical applications. The course also continues the development of Web Programming concepts by examining and using HTML form elements, HTML server controls and web server controls, the ASP.NET Page class, its inherent Page, Request, Response and Cookies objects. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 3
                },
                new Course
                {
                    CourseNumber = "ICT0009",
                    CourseName = "Network Operating Systems",
                    CourseDescription =
                        "Students are introduced to the concepts behind implementing the Windows server and the Linux operating systems in a multiple user, computer and Internet Protocol (IP) networked environment. Topics include managing and updating user accounts, access rights to files and directories, Transmission Control Protocol/Internet Protocol (TCP/IP) and TCP/IP services: Domain Name System (DNS), Hyper Text Transfer Protocol (HTTP) and File Transfer Protocol (FTP). The course reinforces theory with practical lab assignments to install and configure both operating systems and the services mentioned. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 4
                },
                new Course
                {
                    CourseNumber = "ICT0010",
                    CourseName = "Web Imaging and Animations",
                    CourseDescription =
                        "Students are introduced to basic concepts and techniques used to produce graphics, animations and video optimized for the World Wide Web. Students use Adobe software to create images and animations, build graphical user interfaces and author interactive applications. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 4
                },
                new Course
                {
                    CourseNumber = "ICT0011",
                    CourseName = "Communications I",
                    CourseDescription =
                        "Communication remains an essential skill sought by employers, regardless of discipline or field of study. Using a practical, vocation-oriented approach, students focus on meeting the requirements of effective communication. Through a combination of lectures, exercises, and independent learning, students practise writing, speaking, reading, listening, locating and documenting information, and using technology to communicate professionally. Students develop and strengthen communication skills that contribute to success in both educational and workplace environments. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 2
                },
                new Course
                {
                    CourseNumber = "ICT0012",
                    CourseName = "Web Programming Languages I",
                    CourseDescription =
                        "Emphasis is placed on ways of moving data between web pages and databases using the .NET platform: ASP, ADO, C#, and the .NET Framework. Heavy emphasis is placed on how web applications can interact with databases through ODBC or other technologies. Server-side methods and the advantages of multi-tiered applications are explored. The course concludes with a mini-project to develop a live web application that interacts with a database. - See more at: http://www3.algonquincollege.com/sat/program/internet-applications-web-development/#courses",
                    WeeklyHours = 6
                }
                );
        }