public async Task <IActionResult> PutPreviousSchoolInfo(int id, PreviousSchoolInfo previousSchoolInfo)
        {
            if (id != previousSchoolInfo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(previousSchoolInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PreviousSchoolInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <PreviousSchoolInfo> > PostPreviousSchoolInfo(PreviousSchoolInfo previousSchoolInfo)
        {
            _context.PreviousSchoolInfos.Add(previousSchoolInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPreviousSchoolInfo", new { id = previousSchoolInfo.Id }, previousSchoolInfo));
        }
        public ActionResult Index(FormCollection form)
        {
            //  ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            String firstname = "";
            String lastname  = "";
            String email     = "";
            String password  = "";


            firstname = form["fname"].ToString();
            lastname  = form["lname"].ToString();
            email     = form["email"].ToString();
            password  = form["password"].ToString();
            String cs = ConfigurationManager.ConnectionStrings["CEASYS"].ConnectionString;

            using (SqlConnection con = new SqlConnection(cs))
            {
                try
                {
                    con.Open(); // Does the connection with database
                    // ViewBag.Message = "Connection is sucessful";
                    var insertCommand = "INSERT INTO Student_Profile(FirstName, LastName, Email,Password) Values('" + firstname + "','" + lastname + "','" + email + "','" + password + "')";
                    //insertCommand.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = firstName;
                    //cmd.Parameters.Add("@Lastname", SqlDbType.VarChar, 50).Value = lastName;
                    //cmd.Parameters.Add("@Username", SqlDbType.VarChar, 50).Value = userName;
                    //cmd.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = password;
                    //cmd.Parameters.Add("@Age", SqlDbType.Int).Value = age;
                    //cmd.Parameters.Add("@Gender", SqlDbType.VarChar, 50).Value = gender;
                    //cmd.Parameters.Add("@Contact", SqlDbType.VarChar, 50).Value = contact;
                    using (SqlCommand cmd = new SqlCommand(insertCommand, con))
                    {
                        cmd.ExecuteNonQuery();
                        var studentdata = context.Student_Profile.Where(s => s.Email == email).Select(s => s).FirstOrDefault();
                        var addressInfo = new AddressStudent();
                        addressInfo.StudentId = studentdata.StudentId;
                        var citizenshipInfo = new CitizenShipInfo();
                        citizenshipInfo.StudentId = studentdata.StudentId;
                        var academicinfo = new AcademicInfo();
                        academicinfo.StudentId = studentdata.StudentId;
                        var preSchholInfo = new PreviousSchoolInfo();
                        preSchholInfo.StudentId = studentdata.StudentId;
                        var greExam   = new ExamInfo();
                        var toeflExam = new ExamInfo();
                        var IeltsExam = new ExamInfo();
                        greExam.StudentId = toeflExam.StudentId = IeltsExam.StudentId = studentdata.StudentId;
                        var workInfo = new WorkInfo();
                        workInfo.StudentId = studentdata.StudentId;

                        context.Entry(addressInfo).State     = System.Data.EntityState.Added;
                        context.Entry(citizenshipInfo).State = System.Data.EntityState.Added;
                        context.Entry(academicinfo).State    = System.Data.EntityState.Added;
                        context.Entry(preSchholInfo).State   = System.Data.EntityState.Added; //
                        context.Entry(greExam).State         = System.Data.EntityState.Added;
                        context.Entry(toeflExam).State       = System.Data.EntityState.Added;
                        context.Entry(IeltsExam).State       = System.Data.EntityState.Added;
                        context.Entry(workInfo).State        = System.Data.EntityState.Added;//

                        context.SaveChanges();


                        TempData["RegisterMsg"] = "Registration has been completed!!";
                    }
                } // end try
                catch (Exception e)  // catches the exception message
                {
                    TempData["RegisterMsg"] = "Email Already registered.Please try with different email";
                } // end catch
                finally
                {
                    con.Close(); //Closes the connection to database
                }
            }



            return(RedirectToAction("Index"));
        }