public void Update(TenantModel tenant) { FirstName = tenant.FirstName; LastName = tenant.LastName; TelephoneNumber = tenant.TelephoneNumber; Email = tenant.Email; }
public IHttpActionResult PostTenant(TenantModel tenant) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var dbTenant = new Tenant(); dbTenant.Update(tenant); db.Tenants.Add(dbTenant); db.SaveChanges(); tenant.TenantId = dbTenant.TenantId; return CreatedAtRoute("DefaultApi", new { id = tenant.TenantId }, tenant); }
public IHttpActionResult PutTenant(int id, TenantModel tenant) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tenant.TenantId) { return BadRequest(); } var dbTenant = db.Tenants.Find(id); dbTenant.Update(tenant); db.Entry(dbTenant).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TenantExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }