コード例 #1
0
        public async Task <bool> UpdateBankAccountAsync(BankAccount bankAccount)
        {
            try
            {
                var excluded = new[] { "ID" };
                var entry    = _context.Entry(bankAccount);
                entry.State = EntityState.Modified;
                foreach (var name in excluded)
                {
                    entry.Property(name).IsModified = false;
                }
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                //Error handle
                return(false);
            }
        }
コード例 #2
0
        public async Task <bool> UpdateUserAsync(User user)
        {
            try
            {
                var excluded = new[] { "Password", "LastLoginDate" };
                var entry    = _context.Entry(user);
                entry.State = EntityState.Modified;
                foreach (var name in excluded)
                {
                    entry.Property(name).IsModified = false;
                }

                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                //Error handle
                return(false);
            }
        }