public Department CreateDepartment(Department department)
 {
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             context.Departments.AddObject(department);
             context.SaveChanges();
             ts.Complete();
             return department;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public Department UpdateDepartment(Department department)
 {
     try
     {
         Department persistedDepartment = (from d in context.Departments
                                           where d.DepartmentID == department.DepartmentID
                                           select d).First<Department>();
         CollectionPoint point = (from cp in context.CollectionPoints
                               where cp.CollectionPointID == department.CollectionPointID
                               select cp).First();
         using (TransactionScope ts = new TransactionScope())
         {
             persistedDepartment.CollectionPoint = point;
             persistedDepartment.Code = department.Code;
             persistedDepartment.Name = department.Name;
             persistedDepartment.IsBlackListed = department.IsBlackListed;
             context.SaveChanges();
             ts.Complete();
             return persistedDepartment;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// Get Requisitions by department
        /// </summary>
        /// <param name="department">department object</param>
        /// <param name="requisitionSearchDTO">requisitionSearchDTO object</param>
        /// <returns>List of VW_RequisitionsByDepartment objects</returns>
        public List<VW_RequisitionsByDepartment> GetRequisitionByDepartmentID(Department department, RequisitionSearchDTO requisitionSearchDTO)
        {
            try
            {
                return GetAllRequisitionByDepartment()
                .Where(ri => ri.DepartmentID == (department.DepartmentID == 0 ? ri.DepartmentID : department.DepartmentID))
                .ToList<VW_RequisitionsByDepartment>();
            }
            catch (Exception)
            {

                throw;
            }
        }
 public void DeleteDepartment(Department department)
 {
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             context.Departments.Attach(department);
             context.Departments.DeleteObject(department);
             context.SaveChanges();
             ts.Complete();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public Department CreateDepartment(Department department)
 {
     return udao.CreateDepartment(department);
 }
 public void DeleteDepartment(Department department)
 {
     udao.DeleteDepartment(department);
 }
 public Department UpdateDepartment(Department department)
 {
     return udao.UpdateDepartment(department);
 }
 /// <summary>
 /// Get requisition List by department
 /// </summary>
 /// <param name="department">department object</param>
 /// <param name="requisitionSearchDTO">RequisitionSearchDTO object</param>
 /// <returns>List of VW_RequisitionsByDepartment</returns>
 public List<VW_RequisitionsByDepartment> GetRequisitionByDepartment(Department department, RequisitionSearchDTO requisitionSearchDTO)
 {
     List<VW_RequisitionsByDepartment> temp = requisitionDAO.GetRequisitionByDepartmentID(department, requisitionSearchDTO);
     if (temp != null)
     {
         return temp;
     }
     ErrorMessage("Result Not Found");
     return null;
 }
 /// <summary>
 /// Get All Pending Request by Department
 /// </summary>
 /// <param name="department"></param>
 /// <returns></returns>
 public List<VW_PendingRequestNotification> GetPendingRequest(Department department)
 {
     return null;//return requisitionDAO.GetPendingRequest(department);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Departments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDepartments(Department department)
 {
     base.AddObject("Departments", department);
 }
 /// <summary>
 /// Create a new Department object.
 /// </summary>
 /// <param name="departmentID">Initial value of the DepartmentID property.</param>
 /// <param name="collectionPointID">Initial value of the CollectionPointID property.</param>
 /// <param name="code">Initial value of the Code property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="isBlackListed">Initial value of the IsBlackListed property.</param>
 public static Department CreateDepartment(global::System.Int32 departmentID, global::System.Int32 collectionPointID, global::System.String code, global::System.String name, global::System.Boolean isBlackListed)
 {
     Department department = new Department();
     department.DepartmentID = departmentID;
     department.CollectionPointID = collectionPointID;
     department.Code = code;
     department.Name = name;
     department.IsBlackListed = isBlackListed;
     return department;
 }