public IHttpActionResult PutCustomer(int id, Customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != customer.Id) { return BadRequest(); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCustomer(Customer customer) { customer.RegistrationId = "1"; customer.GSTRegistrationId = "1"; //customer.PaymentTermId = 0; customer.ContextCompanyId = 0; customer.ContextLocationId = 0; customer.ParentCustomerId = 0; customer.CompanyId = 1; customer.LocationId = 1; customer.Createdby = 1; if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Customers.Add(customer); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = customer.Id }, customer); }