Beispiel #1
0
        public async Task <IActionResult> PutTenant(int UserId, Tenant Tenant)
        {
            if (UserId != Tenant.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(Tenant).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TenantExists(UserId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,UnitNumber,AptName,Reason,PhonNum,Permission,DateReq")] Tenant tenant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tenant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tenant));
 }
        public async Task <IActionResult> PutTenant(long id, Tenant tenant)
        {
            if (id != tenant.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tenant).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        /// <summary>
        /// Updates values associated to a tenant.
        /// </summary>
        /// <param name="tenant">The tenant with changed values</param>
        public async Task UpdateAsync(Lib.Models.Tenant tenant)
        {
            var currentTenant = await _context.Tenant.FindAsync(tenant.Id);

            if (currentTenant == null)
            {
                throw new InvalidOperationException("Invalid Tenant Id");
            }

            var newTenant = _mapper.MapTenant(tenant);

            _context.Entry(currentTenant).CurrentValues.SetValues(newTenant);
        }