public virtual async Task <Output <SalesOrder_ReadOutput> > ReadAsync(int _salesOrderId) { SalesOrder_ReadOutput res = new SalesOrder_ReadOutput(); try { currentErrors.AbortIfHasErrors(); // CUSTOM_CODE_START: add custom security checks for Read operation below // CUSTOM_CODE_END SalesOrder obj = await ctx.FindEntityAsync <SalesOrder>(currentErrors, _salesOrderId); ServiceUtil.CopyProperties(obj, res); // CUSTOM_CODE_START: populate the Customer output structure of Read operation below res.Customer = GetCustomerInfo(obj); // CUSTOM_CODE_END // CUSTOM_CODE_START: populate the Payment output structure of Read operation below res.Payment = GetPaymentInfo(obj); // CUSTOM_CODE_END // CUSTOM_CODE_START: populate the Sales output structure of Read operation below res.Sales = GetSalesInfo(obj); // CUSTOM_CODE_END // CUSTOM_CODE_START: add custom code for Read operation below // CUSTOM_CODE_END } catch (Exception ex) { currentErrors.MergeWith(errorParser.FromException(ex)); } return(await Task.FromResult(new Output <SalesOrder_ReadOutput>(currentErrors, res))); }
public virtual SalesOrder_ReadOutput Read(int _salesOrderId) { SalesOrder_ReadOutput res = new SalesOrder_ReadOutput(); using (AdventureWorksEntities ctx = new AdventureWorksEntities()) { SalesOrder obj = ctx.SalesOrder.Find(_salesOrderId); if (obj == null) { ErrorList.Current.CriticalError(HttpStatusCode.NotFound, "SalesOrder with id {0} not found", _salesOrderId); } ServiceUtil.CopyProperties(obj, res); // CUSTOM_CODE_START: populate the Customer output structure of Read operation below res.Customer = GetCustomerInfo(obj); // CUSTOM_CODE_END // CUSTOM_CODE_START: populate the Payment output structure of Read operation below res.Payment = GetPaymentInfo(obj); // CUSTOM_CODE_END // CUSTOM_CODE_START: populate the Sales output structure of Read operation below res.Sales = GetSalesInfo(obj); // CUSTOM_CODE_END // CUSTOM_CODE_START: add custom code for Read operation below // CUSTOM_CODE_END } return(res); }