Example #1
0
        public bool ChangeShipingAddress(int pCustomerID, int pSalesOrderID, int pAddressID)
        {
            var _result = false;

            using (var db = new AdventureWorks2016CTP3Entities())
            {
                SalesOrderHeader _SalesOrderHeaders = db.SalesOrderHeaders.FirstOrDefault(s => s.SalesOrderID == pSalesOrderID);

                _SalesOrderHeaders.BillToAddressID = pAddressID;

                db.SaveChanges();
                _result = true;
            }
            return(_result);
        }
Example #2
0
        public bool SaveNewItemToOrder(int pCustomerID, SalesOrderDetail pSalesOrderDetail)
        {
            using (var db = new AdventureWorks2016CTP3Entities())
            {
                pSalesOrderDetail.rowguid = Guid.NewGuid();
                db.SalesOrderDetails.Add(pSalesOrderDetail);

                SalesOrderHeader _SalesOrderHeader = db.SalesOrderHeaders.Where(t => t.SalesOrderID == pSalesOrderDetail.SalesOrderID).FirstOrDefault();
                _SalesOrderHeader.SubTotal = _SalesOrderHeader.SubTotal + pSalesOrderDetail.LineTotal;
                _SalesOrderHeader.TotalDue = _SalesOrderHeader.TotalDue + pSalesOrderDetail.LineTotal;

                db.SaveChanges();

                return(true);
            }
        }