Beispiel #1
0
 public void Dispose()
 {
     if (_context != null)
     {
         _context.Dispose();
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #3
0
 public virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     this._disposed = true;
 }
Beispiel #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     disposed = true;
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_context != null)
         {
             _context.Dispose();
             _context = null;
         }
     }
 }
Beispiel #6
0
        public IActionResult UpdateList(Todolist obj)
        {
            var oldTask = db.Todolist.Find(obj.Id);

            oldTask.IsCompleted = obj.IsCompleted;
            //db.Entry(obj).State = EntityState.Modified;

            db.SaveChanges();
            db.Dispose();

            return(new ObjectResult("Task Completed!"));
        }
Beispiel #7
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    _todoContext.Dispose();
                }
            }

            _disposed = true;
        }
Beispiel #8
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    if (_context != null)
                    {
                        _context.Dispose();
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Beispiel #9
0
        public User Authenticate(string username, string password)
        {
            var user = _context.User.SingleOrDefault(x => x.Username == username);

            // return null if user not found.
            if (user == null)
            {
                return(null);
            }

            // We found the record for that user, now we compare the passwords

            var hashedPassword = BCrypt.Net.BCrypt.HashPassword(password);

            if (!BCrypt.Net.BCrypt.Verify(password, hashedPassword))
            {
                return(null);
            }

            // authentication successful so generate jwt token
            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(_appSettings.Secret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, user.Id.ToString())
                }),
                Expires            = DateTime.UtcNow.AddMinutes(30),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            user.Token = tokenHandler.WriteToken(token);

            // remove password before returning
            user.Password = null;

            _context.Dispose();

            return(user);
        }
 public void Dispose()
 {
     _context.Dispose();
 }
Beispiel #11
0
 /// <summary>
 /// 保存数据到数据库
 /// </summary>
 public virtual void SaveChanges()
 {
     _db.SaveChanges();
     _db.Dispose();
 }
Beispiel #12
0
 protected override void Dispose(bool disposing)
 {
     sql.Dispose();
     base.Dispose(disposing);
 }
Beispiel #13
0
 public void TearDown()
 {
     _todosContext.Dispose();
 }
Beispiel #14
0
 public static void ClassCleanup()
 {
     _dbcontext.Dispose();
 }
Beispiel #15
0
 public void Dispose()
 {
     _ToDOContext.Dispose();
 }