public IHttpActionResult PutLease(int id, LeaseModel lease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != lease.LeaseId) { return BadRequest(); } var dblease = db.Leases.Find(id); dblease.Update(lease); db.Entry(dblease).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LeaseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public void Update(LeaseModel model) { StartDate = model.StartDate; EndDate = model.EndDate; RentAmount = model.RentAmount; }
public void Update(LeaseModel lease) { TenantId = lease.TenantId; PropertyId = lease.PropertyId; StartDate = lease.StartDate; EndDate = lease.EndDate; RentAmount = lease.RentAmount; RentFrequency = lease.RentFrequency; }
public void Update(LeaseModel model) { LeaseId = model.LeaseId; TenantId = model.TenantId; PropertyId = model.PropertyId; StartDate = model.StartDate; EndDate = model.EndDate; RentAmount = model.RentAmount; RentFrequency = model.RentFrequency; }
public IHttpActionResult PostLease(LeaseModel lease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var dbLease = new Lease(lease); db.Leases.Add(dbLease); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = lease.LeaseId }, lease); }
public IHttpActionResult PutLease(int id, LeaseModel lease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != lease.LeaseId) { return BadRequest(); } #region Thing to change Lease dbLease = db.Leases.FirstOrDefault(l => l.Property.User.UserName == User.Identity.Name && l.LeaseId == id); if (dbLease == null) { return BadRequest(); } dbLease.Update(lease); db.Entry(dbLease).State = EntityState.Modified; #endregion Thing to change try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LeaseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public Lease(LeaseModel model) { this.Update(model); }
public IHttpActionResult PostLease(LeaseModel lease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var dbLease = new Lease(lease); dbLease.Property.User = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name); db.Leases.Add(dbLease); db.SaveChanges(); lease.LeaseId = dbLease.LeaseId; return CreatedAtRoute("DefaultApi", new { id = dbLease.LeaseId }, lease); }
public IHttpActionResult PostLease(LeaseModel lease) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var dbLease = new Lease(); // Lease doesn't need the following code in POST because it's not being created directly by the user // dbLease.User = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name); dbLease.Update(lease); db.Leases.Add(dbLease); db.SaveChanges(); lease.LeaseId = dbLease.LeaseId; return CreatedAtRoute("DefaultApi", new { id = lease.LeaseId }, lease); }
public Lease(LeaseModel lease) { this.Update(lease); }