Ejemplo n.º 1
0
 public bool UpdateDepartment(xPlug.BusinessObject.Department department)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = DepartmentMapper.Map <xPlug.BusinessObject.Department, Department>(department);
         if (myEntityObj == null)
         {
             return(false);
         }
         using (var db = new ExpenseManagerDBEntities())
         {
             db.Departments.Attach(myEntityObj);
             db.ObjectStateManager.ChangeObjectState(myEntityObj, EntityState.Modified);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
 public int AddDepartment(xPlug.BusinessObject.Department department)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = DepartmentMapper.Map <xPlug.BusinessObject.Department, Department>(department);
         if (myEntityObj == null)
         {
             return(-2);
         }
         using (var db = new ExpenseManagerDBEntities())
         {
             db.AddToDepartments(myEntityObj);
             db.SaveChanges();
             department.DepartmentId = myEntityObj.DepartmentId;
             return(department.DepartmentId);
         }
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }