示例#1
0
        public LmsUser GetByAspNetId(string aspNetId)
        {
            LmsUser user = new LmsUser();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("ASPNetIDGet", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@AspNetID", aspNetId);

                cn.Open();

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        user.UserID = (int) dr["UserID"];
                        user.FirstName = dr["FirstName"].ToString();
                        user.LastName = dr["LastName"].ToString();
                        user.Email = dr["Email"].ToString();
                        user.SuggestedRole = dr["SuggestedRole"].ToString();

                        //if (dr["GradeLevel"] != DBNull.Value)
                        //    user.GradeLevelID = (byte) dr["GradeLevelID"];
                    }
                }
            }
            return user;
        }
示例#2
0
        public void PopulateVM(List<GradeLevel> gradeLevels, List<string> userRoles, LmsUser user)
        {
            //UserRoles = userRoles;
            GradeLevelList = new List<SelectListItem>();

            foreach (var g in gradeLevels)
            {
                GradeLevelList.Add(new SelectListItem { Text = g.GradeLevelName, Value = g.GradeLevelId.ToString() });
            }

            AllRoles = new List<RoleCheckbox>()
            {
                new RoleCheckbox() { RoleName = "Admin", IsChecked = userRoles.Contains("Admin")},
                new RoleCheckbox() { RoleName = "Teacher", IsChecked = userRoles.Contains("Teacher")},
                new RoleCheckbox() { RoleName = "Parent", IsChecked = userRoles.Contains("Parent")},
                new RoleCheckbox() { RoleName = "Student", IsChecked = userRoles.Contains("Student")}
            };

            FirstName = user.FirstName;
            LastName = user.LastName;
            UserName = user.Email;
            SuggestedRole = user.SuggestedRole;
            GradeLevelId = user.GradeLevelId;
            UserId = user.UserId;
        }
        public List<LmsUser> GetStudents(int UserID)
        {
            List<LmsUser> students = new List<LmsUser>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("UserParentDashboard", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserID", UserID);

                cn.Open();
                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var student = new LmsUser();
                        student.UserID = (int)dr["UserID"];
                        student.FirstName = dr["FirstName"].ToString();
                        student.LastName = dr["LastName"].ToString();

                        students.Add(student);
                    }
                }
            }
            return students;
        }
示例#4
0
        public LmsUser GetUnassignedUserDetails(int UserID)
        {
            LmsUser user = new LmsUser();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("UserViewDetails", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserID", UserID);

                cn.Open();
                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        user.UserID = (int) dr["UserID"];
                        user.ID = dr["ID"].ToString();
                        user.FirstName = dr["FirstName"].ToString();
                        user.LastName = dr["LastName"].ToString();
                        user.Email = dr["Email"].ToString();
                        user.SuggestedRole = dr["SuggestedRole"].ToString();

                        if (dr["GradeLevelID"] != DBNull.Value)
                            user.GradeLevelID = (byte) dr["GradeLevelID"];
                    }
                }
            }
            return user;
        }
        public void CreateInvalidUserIsRejected()
        {
            var newUser = new LmsUser()
            {
                Email = null,
                FirstName = "Uh oh, stuff is missing here!"
            };

            var response = _lmsUserManager.CreateUser(newUser);

            Assert.IsFalse(response.Success);
            Console.WriteLine(response.Message);
        }
示例#6
0
        // Lis 6/28
        public Response Create(LmsUser user)
        {
            var response = new Response();
            try
            {
                _lmsUserRepository.Create(user);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }

            return response;
        }
        public void CreateValidUserIsSuccess()
        {
            var newUser = new LmsUser()
            {
                Email = "*****@*****.**",
                FirstName = "Gerald",
                LastName = "Success"
            };

            var response = _lmsUserManager.CreateUser(newUser);

            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Data);
            Console.WriteLine(response.Data);
        }
        public int CreateUser(LmsUser user)
        {
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var p = new DynamicParameters();
                p.Add("@AspId", user.AspId);
                p.Add("@LastName", user.LastName);
                p.Add("@FirstName", user.FirstName);
                p.Add("@Email", user.Email);
                p.Add("@SuggestedRole", user.SuggestedRole);
                p.Add("@GradeLevelId", user.GradeLevelId);
                p.Add("@UserId", direction: ParameterDirection.Output, dbType: DbType.Int32);

                cn.Execute("spAddUser", p, commandType: CommandType.StoredProcedure);

                return p.Get<int>("@UserId");

            }
        }
示例#9
0
        public void CanCreateUser()
        {
            var user = new LmsUser()
            {
                FirstName = "Deedee",
                LastName = "Dee",
                Email = "*****@*****.**",
                GradeLevelId = 3,
                SuggestedRole = "Student"
            };

            var newId = _repo.CreateUser(user);

            Assert.IsTrue(newId > 0);

            var afterResult = _repo.GetLmsUserById(newId);

            Assert.IsTrue(afterResult.FirstName == "Deedee");
        }
示例#10
0
        public void Create(LmsUser user)
        {
            user.ID = Guid.NewGuid().ToString();
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("LmsUserAdd", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Id", user.ID);
                cmd.Parameters.AddWithValue("@Email", user.Email);
                cmd.Parameters.AddWithValue("@FirstName", user.FirstName);
                cmd.Parameters.AddWithValue("@LastName", user.LastName);
                cmd.Parameters.AddWithValue("@SuggestedRole", user.SuggestedRole);
                cmd.Parameters.AddWithValue("@GradeLevelID", user.GradeLevelID);
                cmd.Parameters.AddWithValue("@UserId", user.UserID).Direction = ParameterDirection.Output;
                cn.Open();
                cmd.ExecuteNonQuery();
                int ans = (int)cmd.Parameters["@UserId"].Value;
                user.UserID = ans;
            }
        }
示例#11
0
        public static Response Validate(LmsUser user)
        {
            var response = new Response();
            if (string.IsNullOrEmpty(user.FirstName))
            {
                response.Message = "First name cannot be empty.";
            }
            else if (string.IsNullOrEmpty(user.LastName))
            {
                response.Message = "Last name cannot be empty.";
            }
            else if (string.IsNullOrEmpty(user.Email))
            {
                response.Message = "Email cannot be empty.";
            }

            if (string.IsNullOrEmpty(response.Message))
            {
                response.Success = true;
            }
            return response;
        }
示例#12
0
        public DataResponse<int> CreateUser(LmsUser user)
        {
            var response = new DataResponse<int>();

            var validation = Validator.Validate(user);
            if (!validation.Success)
            {
                response.Message = validation.Message;
                return response;
            }

            try
            {
                response.Data = _lmsUserRepository.CreateUser(user);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }

            return response;
        }
示例#13
0
        public LmsUser GetUnassignedUserDetails(int UserID)
        {
            LmsUser user = new LmsUser();

            return user;
        }
示例#14
0
        public async Task<ActionResult> Register(RegisterViewModel registerViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = registerViewModel.Email, Email = registerViewModel.Email };
                var result = await UserManager.CreateAsync(user, registerViewModel.Password);
                if (result.Succeeded)
                {
                    var lmsUser = new LmsUser();
                    lmsUser.Email = registerViewModel.Email;
                    lmsUser.FirstName = registerViewModel.FirstName;
                    lmsUser.LastName = registerViewModel.LastName;
                    lmsUser.AspId = user.Id;
                    lmsUser.GradeLevelId = registerViewModel.GradeLevelId;
                    lmsUser.SuggestedRole = registerViewModel.SuggestedRole;

                    var lmsResponse = _lmsUserManager.CreateUser(lmsUser);

                    if (!lmsResponse.Success)
                    {
                        ViewBag.ErrorMsg = lmsResponse.Message;
                        return View("Error");
                    }



                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string 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, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("NotApprovedYet", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            var gradeLevelResponse = _lmsUserManager.GetAllGradeLevels();
            if (gradeLevelResponse.Success)
            {
                var vm = new LoginRegistrationVM();
                vm.RegisterViewModel = registerViewModel;
                vm.RegisterViewModel.PopulateLists(gradeLevelResponse.Data);
                return View("~/Views/Home/Index.cshtml", vm);
            }
            else
            {
                ViewBag.ErrorMsg = gradeLevelResponse.Message;
                return View("Error");
            }
        }
示例#15
0
        public List<LmsUser> GetUnassignedUsers()
        {
            List<LmsUser> users = new List<LmsUser>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("LMSUserSelectUnassigned", cn); //Name of Eric's sproc--AdministratorDashboard
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();
                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var user = new LmsUser();
                        user.UserID = (int) dr["UserID"];
                        //user.Id = dr["ID"].ToString();
                        user.FirstName = dr["FirstName"].ToString();
                        user.LastName = dr["LastName"].ToString();
                        user.Email = dr["Email"].ToString();
                        user.SuggestedRole = dr["SuggestedRole"].ToString();

                        if (dr["GradeLevelID"] != DBNull.Value)
                            user.GradeLevelID = (byte) dr["GradeLevelID"];

                        users.Add(user);
                    }
                }
            }
            return users;
        }
 public int CreateUser(LmsUser user)
 {
     throw new System.NotImplementedException();
 }
示例#17
0
        public LmsUser UpdateUserDetails(LMSUserUpdateRequest user)
        {
            LmsUser user1 = new LmsUser();
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("UserUpdateDetails", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserID", user.UserID);
                cmd.Parameters.AddWithValue("@ID", user.ID);
                cmd.Parameters.AddWithValue("@FirstName", user.FirstName);
                cmd.Parameters.AddWithValue("@LastName", user.LastName);
                cmd.Parameters.AddWithValue("@GradeLevelID", user.GradeLevelID);

                cn.Open();
                cmd.ExecuteNonQuery();
            }

            return user1;
        }
示例#18
0
        public List<LmsUser> UserSearch(AdminUserSearch searchName)
        {
            List<LmsUser> users = new List<LmsUser>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("UserSearch", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                if (!string.IsNullOrEmpty(searchName.FirstName))
                    cmd.Parameters.Add(new SqlParameter("@FirstNamePartial", searchName.FirstName));

                if (!string.IsNullOrEmpty(searchName.LastName))
                    cmd.Parameters.Add(new SqlParameter("@LastNamePartial", searchName.LastName));

                if (!string.IsNullOrEmpty(searchName.Email))
                    cmd.Parameters.Add(new SqlParameter("@EmailPartial", searchName.Email));

                if (!string.IsNullOrEmpty(searchName.SelectedRoleID))
                    cmd.Parameters.Add(new SqlParameter("@RoleID", searchName.SelectedRoleID));

                cn.Open();
                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var user = new LmsUser();
                        user.UserID = (int) dr["UserID"];
                        user.FirstName = dr["FirstName"].ToString();
                        user.LastName = dr["LastName"].ToString();
                        user.Email = dr["Email"].ToString();

                        users.Add(user);
                    }
                }
            }
            return users;
        }
示例#19
0
        public LmsUser UpdateUserDetails(LmsUser user)
        {
            LmsUser user1 = new LmsUser();

            return user1;
        }
        public List<LmsUser> GetUnassignedUsers()
        {
            List<LmsUser> users = new List<LmsUser>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                var cmd = new SqlCommand("spGetAllUnassignedUsers", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();
                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var user = new LmsUser();
                        user.UserId = (int)dr["UserId"];
                        user.AspId = dr["AspId"].ToString();

                        //if (dr["AspId"] != DBNull.Value)
                        //{
                        //    user.AspId = dr["AspId"].ToString();
                        //}
                        user.FirstName = dr["FirstName"].ToString();
                        user.LastName = dr["LastName"].ToString();
                        user.Email = dr["Email"].ToString();
                        user.SuggestedRole = dr["SuggestedRole"].ToString();

                        if (dr["GradeLevelId"] != DBNull.Value)
                            user.GradeLevelId = (byte) dr["GradeLevelId"];

                        users.Add(user);
                    }
                }
            }
            return users;
        }
示例#21
0
 public LmsUser GetByAspNetId(string aspNetId)
 {
     LmsUser user = new LmsUser();
     return user;
 }
示例#22
0
 public void Create(LmsUser user)
 {
     LmsUser user3 = new LmsUser();
 }
示例#23
0
        public async Task<ActionResult> Register(RegisterViewModel RegisterViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = RegisterViewModel.Email, Email = RegisterViewModel.Email };
                var result = await UserManager.CreateAsync(user, RegisterViewModel.Password);

                if (result.Succeeded)
                {
                    var lmsUser = new LmsUser();
                    lmsUser.Email = RegisterViewModel.Email;
                    lmsUser.FirstName = RegisterViewModel.FirstName;
                    lmsUser.LastName = RegisterViewModel.LastName;
                    lmsUser.ID = user.Id;
                    lmsUser.GradeLevelID = RegisterViewModel.GradeLevelID;
                    lmsUser.SuggestedRole = RegisterViewModel.SuggestedRole;

                    _lmsUserManager.Create(lmsUser);

                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string 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, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("NotApprovedYet", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            //return RedirectToAction("Home",RegisterViewModel);
            return View();
        }
示例#24
0
        public LmsUser UpdateUserDetails(LMSUserUpdateRequest user)
        {
            LmsUser user1 = new LmsUser();

            return user1;
        }