示例#1
0
        public async Task <IActionResult> CreateSalesTerritoryHistory([FromBody] Sales.SalesTerritoryHistory value)
        {
            _db.Sales_SalesTerritoryHistory.Add(value);
            await _db.SaveChangesAsync();

            return(Ok(value));
        }
示例#2
0
        public async Task <IActionResult> EditSalesTerritoryHistory(int businessEntityID, DateTime startDate, int territoryID, [FromBody] Sales.SalesTerritoryHistory value)
        {
            var existing = await _db.Sales_SalesTerritoryHistory.FirstOrDefaultAsync(x => x.BusinessEntityID == businessEntityID && x.StartDate == startDate && x.TerritoryID == territoryID);

            if (existing == null)
            {
                return(NotFound());
            }

            existing.BusinessEntityID = value.BusinessEntityID;
            existing.TerritoryID      = value.TerritoryID;
            existing.StartDate        = value.StartDate;
            existing.EndDate          = value.EndDate;
            existing.rowguid          = value.rowguid;
            existing.ModifiedDate     = value.ModifiedDate;

            _db.Sales_SalesTerritoryHistory.Update(existing);
            await _db.SaveChangesAsync();

            return(NoContent());
        }