Exemplo n.º 1
0
        /// <summary>
        /// Delete a business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
#pragma warning disable 1998
        public async Task <DataPortalResponse> Delete(CriteriaRequest request)
#pragma warning restore 1998
        {
            var result = new DataPortalResponse();

            try
            {
                request = ConvertRequest(request);

                // unpack criteria data into object
                object criteria = GetCriteria(request.CriteriaData);
                if (criteria is Csla.DataPortalClient.PrimitiveCriteria)
                {
                    criteria = ((Csla.DataPortalClient.PrimitiveCriteria)criteria).Value;
                }

                var objectType = Csla.Reflection.MethodCaller.GetType(AssemblyNameTranslator.GetAssemblyQualifiedName(request.TypeName), true);
                var context    = new DataPortalContext(
                    (IPrincipal)SerializationFormatterFactory.GetFormatter().Deserialize(request.Principal),
                    true,
                    request.ClientCulture,
                    request.ClientUICulture,
                    (ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(request.ClientContext),
                    (ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(request.GlobalContext));

                var dpr = await dataPortalServer.Delete(objectType, criteria, context, true);

                if (dpr.Error != null)
                {
                    result.ErrorData = new DataPortalErrorInfo(dpr.Error);
                }
                result.ObjectData = SerializationFormatterFactory.GetFormatter().Serialize(dpr.ReturnObject);
            }
            catch (Exception ex)
            {
                result.ErrorData = new DataPortalErrorInfo(ex);
                throw;
            }
            finally
            {
                result = ConvertResponse(result);
            }
            return(result);
        }
Exemplo n.º 2
0
        void DoDelete(object state)
        {
            DeleteTask task = state as DeleteTask;

            task.Result = Portal.Delete(task.ObjectType, task.Criteria, task.Context);
        }