Exemple #1
0
        public async Task <IActionResult> Destroy([FromRoute] int id)
        {
            var user = await _auth.User();

            var account = await(from current in _context.Accounts
                                where current.Id == id && current.UserId == user.Id
                                select current).FirstAsync();

            _context.Remove(account);

            await _context.SaveChangesAsync();

            var response = new ResponseViewModel <int>(account.Id);

            return(Ok(response));
        }
Exemple #2
0
        public async Task <IActionResult> Destroy([FromRoute] int accountId, [FromRoute] int id)
        {
            var user = await _auth.User();

            var revenue = await(from current in _context.Revenues
                                join account in _context.Accounts on current.AccountId equals account.Id
                                where current.AccountId == accountId && current.Id == id && account.UserId == user.Id
                                select current).FirstAsync();

            _context.Remove(revenue);

            await _context.SaveChangesAsync();

            var response = new ResponseViewModel <int>(revenue.Id);

            return(Ok(response));
        }