示例#1
0
 public bool UpdateLiquidAsset(xPlug.BusinessObject.LiquidAsset liquidAsset)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = LiquidAssetMapper.Map <xPlug.BusinessObject.LiquidAsset, LiquidAsset>(liquidAsset);
         if (myEntityObj == null)
         {
             return(false);
         }
         using (var db = new ExpenseManagerDBEntities())
         {
             db.LiquidAssets.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);
     }
 }
示例#2
0
 public int AddLiquidAsset(xPlug.BusinessObject.LiquidAsset liquidAsset)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = LiquidAssetMapper.Map <xPlug.BusinessObject.LiquidAsset, LiquidAsset>(liquidAsset);
         if (myEntityObj == null)
         {
             return(-2);
         }
         using (var db = new ExpenseManagerDBEntities())
         {
             db.AddToLiquidAssets(myEntityObj);
             db.SaveChanges();
             liquidAsset.LiquidAssetId = myEntityObj.LiquidAssetId;
             return(liquidAsset.LiquidAssetId);
         }
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }