public void UpdateCustomer(string update) { List <HybridTest.Models.CustomerModel> oCustomer = new JavaScriptSerializer().Deserialize <List <HybridTest.Models.CustomerModel> >(System.Web.HttpContext.Current.Request["models"]); using (prodigiousEntities db = new prodigiousEntities()) { oCustomer.All(x => { db.Entry(new HybridTest.Customer() { CustomerID = x.CustomerId, NameStyle = x.NameStyle, Title = x.Title, FirstName = x.FirstName, MiddleName = x.MiddleName, LastName = x.LastName, Suffix = x.Suffix, CompanyName = x.CompanyName, SalesPerson = x.SalesPerson, EmailAddress = x.EmailAddress, Phone = x.Phone, PasswordHash = x.PasswordHash, PasswordSalt = x.PasswordSalt, rowguid = x.rowguid, ModifiedDate = x.ModifiedDate }).State = EntityState.Modified; return(true); }); db.SaveChanges(); } }
// PUT api/values/5 public IHttpActionResult Put(int id, Product product) { product.ProductID = id; product.ModifiedDate = DateTime.Now; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductID) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void CreateCustomer(string create) { try { List <HybridTest.Models.CustomerModel> oCustomer = new JavaScriptSerializer().Deserialize <List <HybridTest.Models.CustomerModel> >(System.Web.HttpContext.Current.Request["models"]); using (prodigiousEntities db = new prodigiousEntities()) { var oToInsert = db.Set <Customer>(); oCustomer.All(x => { db.Entry(new HybridTest.Customer() { NameStyle = x.NameStyle, Title = x.Title, FirstName = x.FirstName, MiddleName = x.MiddleName, LastName = x.LastName, Suffix = x.Suffix, CompanyName = x.CompanyName, SalesPerson = x.SalesPerson, EmailAddress = x.EmailAddress, Phone = x.Phone, rowguid = Guid.NewGuid(), PasswordHash = HybridTest.Controllers.CustomerController.ProcessPassword(), PasswordSalt = HybridTest.Controllers.CustomerController.ProcessPassword(), ModifiedDate = DateTime.Now }).State = EntityState.Added; return(true); }); db.SaveChanges(); } } catch (Exception e) { throw e; } }