Ejemplo n.º 1
0
 /// <summary>
 /// Update a business object.
 /// </summary>
 /// <param name="obj">Business object to update.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Update(object obj, DataPortalContext context)
 {
     try
     {
         context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(obj.GetType());
         if (context.FactoryInfo == null)
         {
             var dp = new SimpleDataPortal();
             return(dp.Update(obj, context));
         }
         else
         {
             var dp = new FactoryDataPortal();
             return(dp.Update(obj, context));
         }
     }
     catch (DataPortalException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new DataPortalException(
                   "DataPortal.Update " + Resources.FailedOnServer,
                   ex, new DataPortalResult(obj));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get an existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context)
 {
     try
     {
         context.FactoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
         if (context.FactoryInfo == null)
         {
             var dp = new SimpleDataPortal();
             return(dp.Fetch(objectType, criteria, context));
         }
         else
         {
             var dp = new FactoryDataPortal();
             return(dp.Fetch(objectType, criteria, context));
         }
     }
     catch (DataPortalException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new DataPortalException(
                   "DataPortal.Fetch " + Resources.FailedOnServer,
                   ex, new DataPortalResult());
     }
 }