public void SetUp()
 {
     student = new StudentAddressInfo()
     {
         studentAddress = "Boring Road",
         city           = "Patna",
         state          = "Bihar",
     };
 }
 public void UpdateStudentAddressInfoIntoDatabase(StudentAddressInfo student)
 {
     try
     {
         studentAddressDataAccess.UpdateStudentAddressInfoIntoDatabase(student);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
예제 #3
0
 public StudentAddressInfo DisplayStudentAddressInfoByIdFromDatabase(int id)
 {
     try {
         StudentAddressInfo studentAddress = DisplayStudentAddressInfoFromDatabase().FirstOrDefault(x => x.studentAddressId == id);
         return(studentAddress);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
        public ActionResult AddressInfo()
        {
            try {
                StudentAddressInfo student = new StudentAddressInfo();
                if (Session["studentAddressId"] != null)
                {
                    student = studentAddressBusinessAccess.DisplayStudentAddressInfoByIdFromDatabase((int)Session["studentAddressId"]);
                    return(View("AddressInfo", student));
                }

                return(View("AddressInfo", student));
            }
            catch (Exception exception)
            {
                return(View("Error"));
            }
        }
예제 #5
0
 public void UpdateStudentAddressInfoIntoDatabase(StudentAddressInfo student)
 {
     try
     {
         using (connection)
         {
             SqlCommand sqlCommand = new SqlCommand("UpdateStudentAddressInfoStoredProcedure", connection);
             sqlCommand.CommandType = CommandType.StoredProcedure;
             sqlCommand.Parameters.AddWithValue("@studentAddressId", student.studentAddressId);
             sqlCommand.Parameters.AddWithValue("@studentAddress", student.studentAddress);
             sqlCommand.Parameters.AddWithValue("@city", student.city);
             sqlCommand.Parameters.AddWithValue("@state", student.state);
             sqlCommand.Parameters.AddWithValue("@studentId", Session["studentId"]);
             connection.Open();
             sqlCommand.ExecuteNonQuery();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
 public ActionResult AddressInfo(StudentAddressInfo studentAddressInfo)
 {
     try {
         if (ModelState.IsValid)
         {
             if (Session["studentAddressId"] != null)
             {
                 studentAddressBusinessAccess.UpdateStudentAddressInfoIntoDatabase(studentAddressInfo);
             }
             else
             {
                 studentAddressBusinessAccess.InsertStudentAddressInfoIntoDatabase(studentAddressInfo);
             }
             return(RedirectToAction("QualificationInfo", "Qualification"));
         }
         return(View("AddressInfo"));
     }
     catch (Exception exception)
     {
         return(View("Error"));
     }
 }
예제 #7
0
 public void InsertStudentAddressInfoIntoDatabase(StudentAddressInfo student)
 {
     try
     {
         using (connection)
         {
             SqlCommand sqlCommand = new SqlCommand("InsertStudentAddressInfoStoredProcedure", connection);
             sqlCommand.CommandType = CommandType.StoredProcedure;
             sqlCommand.Parameters.AddWithValue("@studentAddress", student.studentAddress);
             sqlCommand.Parameters.AddWithValue("@city", student.city);
             sqlCommand.Parameters.AddWithValue("@state", student.state);
             sqlCommand.Parameters.AddWithValue("@studentId", Session["studentId"]);
             SqlCommand command = new SqlCommand("SELECT MAX(studentAddressId) FROM dbo.StudentAddressInfo", connection);
             connection.Open();
             sqlCommand.ExecuteNonQuery();
             Session["studentAddressId"] = (Int32)command.ExecuteScalar();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }