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 PostTenant(TenantModel tenant)
        {
            // Validate the request
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            //Set up new Tenant object,
            //  and populate it with the values from
            //  the input TenantModel object
            Tenant dbTenant = new Tenant();
            dbTenant.Update(tenant);

            // Add the new Tenant object to the list of Tenant objects
            db.Tenants.Add(dbTenant);

            // Save the changes to the DB
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {

                throw new Exception("Unable to add the tenant to the database.");
            }

            // Update the TenantModel object with the new tenant ID
            //  that was placed in the Tenant object after the changes
            //  were saved to the DB
            tenant.TenantId = dbTenant.TenantId;
            return CreatedAtRoute("DefaultApi", new { id = dbTenant.TenantId }, tenant);
        }