public async Task <IActionResult> ChangePassword([FromBody] ChangePasswordModel model) { var admin = await _context.Admins.SingleOrDefaultAsync(o => o.AdminId == Convert.ToInt32(User.Identity.Name)); if ((await _adminAuthenticationProvider.AuthenticateAsync(admin.Username ?? admin.Email, model.OldPassword))?.AdminId == admin.AdminId) { admin.Password = CryptoMethods.HashPassword(model.Password); admin.Mustchangepassword = false; await _context.SaveChangesAsync(); return(Ok(admin.AdminId)); } return(BadRequest("Invalid credentials")); }