示例#1
0
 [HttpPut] //Edicion de datos
 public ActionResult Put([FromBody] Models.ModelRequest.CustomerRequest model)
 {
     using (Models.AdventureWorks2019Context db = new Models.AdventureWorks2019Context())
     {
         Models.Customer customer = db.Customers.Find(model.customerId);
         customer.PersonId        = model.personID;
         customer.StoreId         = model.storeId;
         customer.TerritoryId     = model.territoryId;
         db.Entry(customer).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         db.SaveChanges();
     }
     return(Ok());
 }
示例#2
0
 [HttpPost] //Inserción de datos
 public ActionResult Post([FromBody] Models.ModelRequest.CustomerRequest model)
 {
     using (Models.AdventureWorks2019Context db = new Models.AdventureWorks2019Context())
     {
         Models.Customer customer = new Models.Customer();
         customer.PersonId    = model.personID;
         customer.StoreId     = model.storeId;
         customer.TerritoryId = model.territoryId;
         db.Customers.Add(customer);
         db.SaveChanges();
     }
     return(Ok());
 }