protected virtual Output <SalesOrderDetail_CreateOutput> SalesOrder_Detail_Create(object options) { int _salesOrderId = (int)SalesOrderIdProperty.TransportValue; SalesOrderDetail_CreateInput_Data _data = ToDataContract <SalesOrderDetail_CreateInput_Data>(options); using (var s = ServiceProvider.CreateScope()) { var output = s.ServiceProvider.GetService <ISalesOrderService>().Detail_Create(_salesOrderId, _data); FromDataContract(output?.Result, options); return(output); } }
public ActionResult Detail_Create([FromRoute] int _salesOrderId, [FromBody] SalesOrderDetail_CreateInput_Data _data) { ActionResult response = null; try { if (ModelState.IsValid) { Output <SalesOrderDetail_CreateOutput> output = svc.Detail_Create(_salesOrderId, _data); response = StatusCode((int)output.HttpStatus, output); return(response); } else { ModelValidation.AddModelErrors(currentErrors, ModelState); } } catch (Exception ex) { currentErrors.MergeWith(errorsParser.FromException(ex)); } response = StatusCode((int)currentErrors.HttpStatus, new Output(currentErrors)); return(response); }
public virtual async Task <Output <SalesOrderDetail_CreateOutput> > Detail_CreateAsync(int _salesOrderId, SalesOrderDetail_CreateInput_Data _data) { SalesOrderDetail_CreateOutput res = new SalesOrderDetail_CreateOutput(); try { currentErrors.AbortIfHasErrors(); // CUSTOM_CODE_START: add custom security checks for Detail_Create operation below // CUSTOM_CODE_END EntityState state = EntityState.Added; SalesOrderDetail obj = new SalesOrderDetail(); var entry = ctx.Entry(obj); entry.State = state; obj.SalesOrderId = _salesOrderId; entry.CurrentValues.SetValues(_data); await ctx.ValidateKeyAsync <SalesOrder>(currentErrors, "SalesOrderId", _salesOrderId); await ctx.ValidateKeyAsync <SpecialOfferProduct>(currentErrors, "SpecialOfferId, ProductId", _data.SpecialOfferId, _data.ProductId); // CUSTOM_CODE_START: add custom code for Detail_Create operation below UpdateOrderDetail(obj); // CUSTOM_CODE_END currentErrors.AbortIfHasErrors(); await ctx.SaveChangesAsync(); ServiceUtil.CopyProperties(obj, res); } catch (Exception ex) { currentErrors.MergeWith(errorParser.FromException(ex)); } return(await Task.FromResult(new Output <SalesOrderDetail_CreateOutput>(currentErrors, res))); }