public int InsertUser(Applicant model)
        {
            string connectionString = Connstr();
            SqlConnection connection = new SqlConnection(connectionString);

            String username = model.UserName;
            String password = model.Password;
            password = GetHashedText(password);
            String name = model.Name;
            DateTime dob = model.DateOfBirth;
            String Contact = model.ContactNumber;
            String Email = model.EmailId;
            String address = model.Address;
            Double sscp = model.SscPercentage;
            Double hscp = model.HscPercentage;
            Char gradcomp = (model.CompletedGraduation == true) ? 'Y' : 'N';
            Double Gradperc = model.GraduationPercentage  ;
            Char Pgradcomp = (model.CompletedPostGraduation == true) ? 'Y' : 'N';
            Double PGradperc = model.PostGraduationPercentage;
            Char havework = (model.PreviousWorkExperience == true) ? 'Y' : 'N';
            Double workexp = model.WorkExperience;

            string queryString = "INSERT INTO dbo.UserDetails (UserName,Password,Name,DOB,ContactNumber,EmailID,Address,SSCPercent,HSCPercent,GradComplete,GradPercent,PGComplete,PGPercent,HaveWorkExp,WorkExpYears) "+
                "values( @username,@password,@name,@dob,@Contact,@Email,@address,@sscp,@hscp,@gradcomp,@Gradperc,@Pgradcomp,@PGradperc,@havework,@workexp);" ;

            connection.Open();
            SqlCommand command = new SqlCommand(queryString, connection);
            command.Parameters.AddWithValue("@username",username);
            command.Parameters.AddWithValue("@password", password);
            command.Parameters.AddWithValue("@name", name);
            command.Parameters.AddWithValue("@dob", dob);
            command.Parameters.AddWithValue("@Contact", Contact);
            command.Parameters.AddWithValue("@Email", Email);
            command.Parameters.AddWithValue("@address", address);
            command.Parameters.AddWithValue("@sscp", sscp);
            command.Parameters.AddWithValue("@hscp", hscp);
            command.Parameters.AddWithValue("@gradcomp", gradcomp);
            command.Parameters.AddWithValue("@Gradperc", Gradperc);
            command.Parameters.AddWithValue("@Pgradcomp", Pgradcomp);
            command.Parameters.AddWithValue("@PGradperc", PGradperc);
            command.Parameters.AddWithValue("@havework", havework);
            command.Parameters.AddWithValue("@workexp", workexp);
            command.ExecuteNonQuery();
            connection.Close();
            queryString = "SELECT UserID from dbo.UserDetails Where UserName=@username COLLATE Latin1_General_CS_AS;";
            SqlCommand command1 = new SqlCommand(queryString, connection);
            command1.Parameters.AddWithValue("@username",username);
            connection.Open();
            int userid = (int)command1.ExecuteScalar();

            connection.Close();
            return userid;
        }
        public ActionResult Register(Applicant model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    int n = new DataAccess.DataObj().InsertUser(model);
                    Session["UserID"] = n;
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public ActionResult Register()
 {
     Applicant obj = new Applicant();
     obj.WorkExperience = 0;
     obj.PostGraduationPercentage = 0;
     obj.GraduationPercentage = 0;
     return View(obj);
 }