public void AddPOQuote(POQuote poquote) { using (var db = new Entities()) { db.POQuotes.Add(poquote); db.SaveChanges(); } }
public void UpdatePOQuote(POQuote poquote_update) { try { using (var db = new Entities()) { POQuote original = new POQuote { Id = poquote_update.Id }; /// stub model, only has Id var entry = db.Entry(original); entry.State = System.Data.Entity.EntityState.Modified; entry.CurrentValues.SetValues(poquote_update); db.SaveChanges(); } } catch (Exception ex) { } }
// PUT api/<controller>/5 public void Put(int id, [FromBody] POQuote poquote) { _poQuoteRepository.UpdatePOQuote(poquote); }
// POST api/<controller> public void Post([FromBody] POQuote poquote) { _poQuoteRepository.AddPOQuote(poquote); }