예제 #1
0
 public bool createUnits(Units unit)
 {
     try
     {
         //Units newUnit = db.units.Find(unit.unitId);
         //newUnit.unitName = unit.unitName;
         //newUnit.unitCode = unit.unitCode;
         //newUnit.departmentId = unit.departmentId;
         //db.SaveChanges();
         Units unitFound = _unitsRepository.getById(unit.unitId);
         if (unitFound != null)
         {
             unitFound.unitName     = unit.unitName;
             unitFound.unitCode     = unit.unitCode;
             unitFound.departmentId = unit.departmentId;
             _unitOfWork.Commit();
             return(true);
         }
         else
         {
             _unitsRepository.add(unit);
             _unitOfWork.Commit();
             return(true);
         }
     }
     catch (Exception)
     {
         //db.units.Add(unit);
         return(false);
     }
     // return Json(new[] { unit }.ToDataSourceResult(request, ModelState));
 }