コード例 #1
0
        // 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);
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public ActionResult Apply(ApplyViewModels student)
        {
            bool var = s.Post(student);

            if (var == true)
            {
                return(RedirectToAction("Student", "Home"));
            }
            return(View(student));
        }
コード例 #4
0
 public bool Post([FromBody]ApplyViewModels student)
 {
     string username = User.Identity.Name;
     return _studentrepository.InsertStudent(student, username);
 }