コード例 #1
0
        // public async Task<IActionResult> Edit(int id, [Bind("SalesOrderId,SalesOrderDetailId,OrderQty,ProductId,UnitPrice,UnitPriceDiscount,LineTotal,Rowguid,ModifiedDate")] SalesOrderDetail salesOrderDetail)
        public async Task <IActionResult> Edit(int id, [Bind] EditSO command)
        {
            var sod = _context.SalesOrderDetail.First(o => o.SalesOrderDetailId == id);

            if (id != command.SalesOrderDetailId || sod == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.SalesOrderDetail.Update(command.ToEntity(sod));
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalesOrderDetailExists(sod.SalesOrderDetailId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", salesOrderDetail.ProductId);
            //ViewData["SalesOrderId"] = new SelectList(_context.SalesOrderHeader, "SalesOrderId", "SalesOrderNumber", salesOrderDetail.SalesOrderId);
            return(View());
        }
        public async Task Edit_StateUnderTest_ExpectedBehavior1()
        {
            // Arrange
            var    salesOrderDetailsController = this.CreateSalesOrderDetailsController();
            int    id      = 0;
            EditSO command = null;

            // Act
            var result = await salesOrderDetailsController.Edit(
                id,
                command);

            // Assert
            Assert.True(false);
        }