Exemple #1
0
        public async Task <ActionResult <AccountDto> > PutAccount(long id, AccountForUpdateDto accountForUpdate)
        {
            var userGuid = Guid.NewGuid();
            var account  = mapper.Map <Account>(accountForUpdate);

            if (id != account.Id || userGuid != account.UserGuid)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutAccount(int id, Account account)
        {
            if (id != account.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }