public string Save_Department(Department department)
 {
     if (!departmentGatway.IsDepartmentCodeExists(department.Code))
     {
         if (!departmentGatway.IsDepartmentNameExists(department.Name))
         {
             if (departmentGatway.Save_Department(department)>0)
             {
                 return department.Name+"  Department Save Successfully .";
             }
             else
             {
                 return department.Name + " Department Failed to Save !";
             }
         }
         else
         {
             return "Sorry this "+department.Name + " Name Is Duplicate Department Name !";
         }
     }
     else
     {
         return "Sorry this " + department.Code + " Code Is Duplicate Department Code !";
     }
 }
        public List<Department> VieDepartments()
        {
            connection.ConnectionString = connectionString;
            string sqlQuery = "SELECT * FROM Department";
            SqlCommand command = new SqlCommand(sqlQuery, connection);
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            List<Department> departmentsList=new List<Department>();
            while (reader.Read())
            {
                Department departments = new Department
                {
                    Id = Convert.ToInt32(reader["id"]),
                    Code = reader["code"].ToString(),
                    Name = reader["name"].ToString()

                };

                departmentsList.Add(departments);
            }
            reader.Close();
            connection.Close();
            return departmentsList;

        }
 public int Save_Department(Department department)
 {
     connection.ConnectionString = connectionString;
     string sqlQuery="INSERT INTO Department(code,name) VALUES('"+department.Code+"','"+department.Name+"')";
     SqlCommand command=new SqlCommand(sqlQuery,connection);
     connection.Open();
     int isInserted = command.ExecuteNonQuery();
     connection.Close();
     return isInserted;
 }
 public ActionResult Save_Department(Department department)
 {
     ViewBag.Message = departmentManager.Save_Department(department);
     return View();
 }