// Inserts a student in the Student table. It takes the username and email used in the apply form as parameters. public bool InsertStudent(ApplyViewModels student, string username, string email) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.Cnnval("App1DB"))) { string sql = "dbo.spStudent_InsertStudentInfo"; int rowsAffected = connection.Execute(sql, new { UserName = username, Email = email, FirstName = student.FirstName, LastName = student.LastName, DOB = student.DOB, Gender = student.Gender.ToString(), Street = student.Street, City = student.City, Zip = student.Zip, State = student.State, Country = student.Country, PhoneNumber = student.PhoneNumber, Major = student.Major.ToString(), }, commandType: CommandType.StoredProcedure); if (rowsAffected > 0) { return(true); } return(false); } }
public bool Post([FromBody] ApplyViewModels student) { string username = User.Identity.Name; ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindByName(username); string email = user.Email; return(_studentrepository.InsertStudent(student, username, email)); }
public ActionResult Apply(ApplyViewModels student) { bool var = s.Post(student); if (var == true) { return(RedirectToAction("Student", "Home")); } return(View(student)); }
public bool Post([FromBody]ApplyViewModels student) { string username = User.Identity.Name; return _studentrepository.InsertStudent(student, username); }