public long CreateNewStudent(StudentViewModel objViewModel) { Student objStudent = new Student(); objStudent.UserId = objViewModel.UserId; objStudent.CourseId = objViewModel.CourseId; objStudent.DepartmentId = objViewModel.DepartmentId; objStudent.ClassId = objViewModel.ClassId; objStudent.SectionId = objViewModel.SectionId; objStudent.RollNo = objViewModel.RollNo; objStudent.InsertedOn = DateTime.Now; objStudent.InsertedBy = objViewModel.InsertedBy; objStudent.Email = objViewModel.Email; objStudent.OrganizationId = objViewModel.OrganizationId; objStudent.FullName = objViewModel.Profile.FirstName + " " + objViewModel.Profile.LastName; return objStudent.StudentId = this.CreateStudent(objStudent); }
public long CreateStudent(Student objStudent) { var parameters = new { UserId = objStudent.UserId, CourseId = objStudent.CourseId, DepartmentId = objStudent.DepartmentId, ClassId = objStudent.ClassId, SectionId = objStudent.SectionId, RollNo = objStudent.RollNo, InsertedOn = objStudent.InsertedOn, InsertedBy = objStudent.InsertedBy, Email = objStudent.Email, OrganizationId = objStudent.OrganizationId, FullName = objStudent.FullName, }; using (IDbConnection connection = OpenConnection()) { const string storedProcedure = "usp_AddStudent"; int rowsAffected = connection.Execute(storedProcedure, parameters, commandType: CommandType.StoredProcedure); SetIdentity<int>(connection, id => objStudent.StudentId = id); if (rowsAffected > 0) { return objStudent.StudentId; } return -1; } }
public ActionResult RegisterUserStep3(Profile objProfile) { RegistrationToken Token = repository.GetRegistrationCode(objProfile.RegistrationToken); // RegistrationToken objToken = repository.GetRegistrationCode(objProfile.RegistrationToken); StudentContext context = new StudentContext(); Student student = new Student(); Staff staff = new Staff(); if (Token.StaffId != null) { staff = context.Staff.Find(Token.StaffId); } if (Token.StudentId != null) { student = context.Students.Find(Token.StudentId); } //objProfile.RegistrationToken=Toke long userId = WebSecurity.RegisterNewUser(objProfile.UserName, "none", "none", false, objProfile.FirstName, objProfile.LastName, Token.OrganizationId, Token.Token); if (student != null) { student.UserId = userId; } if (staff != null) { staff.UserId = userId; } context.SaveChanges(); DBConnectionString.Profile Profile = new DBConnectionString.Profile(); if (userId != -1) { Profile.UserId = userId; Profile.Title = objProfile.Title; Profile.Address1 = "none"; Profile.Address2 = "none"; Profile.InsertedOn = DateTime.Now; Profile.EmailAddress1 = "*****@*****.**"; Profile.HomeTelephoneNumber = DateTime.Now.Ticks.ToString(); Profile.SecurityQuestionId = 1; Profile.SecurityAnswer = "none"; Profile.DateOfBirth = objProfile.DateOfBirth; Profile.ModifiedOn = null; Profile.MobileNumber = "none"; int recAffected = Convert.ToInt32(Profile.Insert()); string roleName = ((UserRoles)Convert.ToInt16(Token.RoleId)).ToString(); Roles.AddUserToRole(objProfile.UserName, roleName); return RedirectToAction("RegisterUserStep4", new { userId }); } return View("RegisterUserStep3", new { token = Token.Token }); }