public WcfResponse Update(UpdateRequest request) { var result = new WcfResponse(); try { request = ConvertRequest(request); // unpack object object obj = GetCriteria(request.ObjectData); SilverlightRequestProcessor processor = new SilverlightRequestProcessor(); SilverlightUpdateRequest updateRequest = new SilverlightUpdateRequest( obj, (IPrincipal)MobileFormatter.Deserialize(request.Principal), (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext), (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext)); SilverlightResponse updateResponse = processor.Update(updateRequest); if (updateResponse.Error != null) { result.ErrorData = new WcfErrorInfo(updateResponse.Error); } result.GlobalContext = MobileFormatter.Serialize(updateResponse.GlobalContext); result.ObjectData = MobileFormatter.Serialize(updateResponse.Object); } catch (Exception ex) { result.ErrorData = new WcfErrorInfo(ex); } finally { SilverlightRequestProcessor.ClearContext(); } return(ConvertResponse(result)); }
public WcfResponse Create(CriteriaRequest request) { var result = new WcfResponse(); try { request = ConvertRequest(request); // unpack criteria data into object object criteria = GetCriteria(request.CriteriaData); if (criteria is PrimitiveCriteria) { criteria = ((PrimitiveCriteria)criteria).Value; } SilverlightRequestProcessor processor = new SilverlightRequestProcessor(); SilverlightCriteriaRequest createRequest = new SilverlightCriteriaRequest( request.TypeName, criteria, (IPrincipal)MobileFormatter.Deserialize(request.Principal), (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext), (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext)); SilverlightResponse createResponse = processor.Create(createRequest); if (createResponse.Error != null) { result.ErrorData = new WcfErrorInfo(createResponse.Error); } result.GlobalContext = MobileFormatter.Serialize(createResponse.GlobalContext); result.ObjectData = MobileFormatter.Serialize(createResponse.Object); } catch (Exception ex) { result.ErrorData = new WcfErrorInfo(ex); } finally { SilverlightRequestProcessor.ClearContext(); } return(ConvertResponse(result)); }