public void Update(LeaseModel modelLease)
 {
     TenantId = modelLease.TenantId;
     PropertyId = modelLease.PropertyId;
     StartDate = modelLease.StartDate;
     EndDate = modelLease.EndDate;
     RentAmount = modelLease.RentAmount;
     RentFrequency = modelLease.RentFrequency;
 }
        public IHttpActionResult PutLease(int id, LeaseModel modelLease)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != modelLease.LeaseId)
            {
                return BadRequest();
            }

            // 1. Grab the entry from the database
            var dbLease = db.Leases.Find(id);

            // 2. Update the entryfetched from the database
            dbLease.Update(modelLease);

            // 3. Mark entry as modified
            db.Entry(dbLease).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LeaseExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostLease(LeaseModel lease)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var newLease = new Lease();
            newLease.Update(lease);

            db.Leases.Add(newLease);
            db.SaveChanges();

            lease.LeaseId = newLease.LeaseId;

            return CreatedAtRoute("DefaultApi", new { id = lease.LeaseId }, lease);
        }