Пример #1
0
        /// <summary>
        /// Update a business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
#pragma warning disable 1998
        public async Task <DataPortalResponse> Update(UpdateRequest request)
#pragma warning restore 1998
        {
            var result = new DataPortalResponse();

            try
            {
                request = ConvertRequest(request);
                // unpack object
                object obj = GetCriteria(request.ObjectData);

                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.Update(obj, 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);
        }
Пример #2
0
        void DoUpdate(object state)
        {
            UpdateTask task = state as UpdateTask;

            task.Result = Portal.Update(task.Obj, task.Context);
        }