protected virtual async Task <Output> SalesOrder_Detail_UpdateAsync(object options)
        {
            int _salesOrderDetailId = (int)SalesOrderDetailIdProperty.TransportValue;
            SalesOrderDetail_UpdateInput_Data _data = ToDataContract <SalesOrderDetail_UpdateInput_Data>(options);

            using (var s = ServiceProvider.CreateScope())
            {
                var output = await s.ServiceProvider.GetService <ISalesOrderService>().Detail_UpdateAsync(_salesOrderDetailId, _data);

                return(output);
            }
        }
示例#2
0
        protected virtual void btnSave_Click(object sender, EventArgs e)
        {
            obj.Validate(true);
            ErrorList valErr = obj.GetValidationErrors();

            errors.List.DataSource = valErr.Errors;
            errors.List.DataBind();
            if (valErr.HasErrors())
            {
                return;
            }

            ISalesOrderService svcSalesOrder = DI.Resolve <ISalesOrderService>();

            try
            {
                // for new objects create the object and store its key
                if (IsNew)
                {
                    SalesOrderDetail_CreateInput inDetail_Create = new SalesOrderDetail_CreateInput();
                    obj.ToDataContract(inDetail_Create);
                    SalesOrderDetail_CreateOutput outDetail_Create;
                    using (TimeTracker.ServiceCall)
                        outDetail_Create = svcSalesOrder.Detail_Create(inDetail_Create);
                    obj.FromDataContract(outDetail_Create);
                    IsNew = false;
                }
                else
                {
                    SalesOrderDetail_UpdateInput_Data inDetail_Update_Data = new SalesOrderDetail_UpdateInput_Data();
                    obj.ToDataContract(inDetail_Update_Data);
                    using (TimeTracker.ServiceCall)
                        svcSalesOrder.Detail_Update((int)obj.SalesOrderDetailIdProperty.TransportValue, inDetail_Update_Data);
                }
                obj.SetModified(false, true);
                OnSaved(EventArgs.Empty);
            }
            catch (Exception ex)
            {
                errors.List.DataSource = ErrorList.FromException(ex).Errors;
                errors.List.DataBind();
            }
            finally
            {
                if (svcSalesOrder is IDisposable)
                {
                    ((IDisposable)svcSalesOrder).Dispose();
                }
            }
        }
示例#3
0
 public virtual Output Detail_Update(int _salesOrderDetailId, SalesOrderDetail_UpdateInput_Data _data)
 {
     // CUSTOM_CODE_START: add custom security checks for Detail_Update operation below
     // CUSTOM_CODE_END
     try
     {
         SalesOrderDetail obj = ctx.FindEntity <SalesOrderDetail>(currentErrors, _salesOrderDetailId);
         var entry            = ctx.Entry(obj);
         entry.CurrentValues.SetValues(_data);
         ctx.ValidateKey <SpecialOfferProduct>(currentErrors, "SpecialOfferId, ProductId", _data.SpecialOfferId, _data.ProductId);
         // CUSTOM_CODE_START: add custom code for Detail_Update operation below
         // CUSTOM_CODE_END
         currentErrors.AbortIfHasErrors();
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         currentErrors.MergeWith(errorParser.FromException(ex));
     }
     return(new Output(currentErrors));
 }
示例#4
0
 public virtual void Detail_Update(int _salesOrderDetailId, SalesOrderDetail_UpdateInput_Data _data)
 {
     using (AdventureWorksEntities ctx = new AdventureWorksEntities())
     {
         SalesOrderDetail obj = ctx.SalesOrderDetail.Find(_salesOrderDetailId);
         if (obj == null)
         {
             ErrorList.Current.CriticalError(HttpStatusCode.NotFound, "SalesOrderDetail with id {0} not found", _salesOrderDetailId);
         }
         var entry = ctx.Entry(obj);
         entry.CurrentValues.SetValues(_data);
         // CUSTOM_CODE_START: use the SpecialOfferId input parameter of Detail_Update operation below
         // TODO: ??? = _data.SpecialOfferId; // CUSTOM_CODE_END
         // CUSTOM_CODE_START: use the ProductId input parameter of Detail_Update operation below
         // TODO: ??? = _data.ProductId; // CUSTOM_CODE_END
         // CUSTOM_CODE_START: add custom code for Detail_Update operation below
         // CUSTOM_CODE_END
         ErrorList.Current.AbortIfHasErrors(HttpStatusCode.BadRequest);
         ctx.SaveChanges();
     }
 }
示例#5
0
        public ActionResult Detail_Update([FromRoute] int _salesOrderDetailId, [FromBody] SalesOrderDetail_UpdateInput_Data _data)
        {
            ActionResult response = null;

            try
            {
                if (ModelState.IsValid)
                {
                    Output output = svc.Detail_Update(_salesOrderDetailId, _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);
        }