public async Task <RequestModel> Authorization([FromForm, SwaggerParameter("Login of user", Required = true)] string login, [FromForm, SwaggerParameter("Orginal password of user", Required = true)] string password) { if (login.IsNullOrEmpty() || password.IsNullOrEmpty()) { return(await RequestModel.NotAccessAsync()); } var user = _context.Users.FirstOrDefault(u => u.Login == login && u.HashPassword == Encryptor.SH1Hash(password)); if (user == null) { return(await RequestModel.NotAccessAsync()); } var(accessToken, refreshToken, hashToken) = await GenerateToken(user : user); user.Token = hashToken; user.RefreshToken = refreshToken; user.LastOnline = DateTime.Now; _context.Update(user); await _context.SaveChangesAsync(); var authInfo = new { accessToken, refreshToken }; return(await RequestModel.SuccessAsync(authInfo)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,company,title,job_number,last_checked,last_updated,date_applied,status,notes,interview,rejected,city,state,country")] JobsModel jobsModel) { if (id != jobsModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jobsModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobsModelExists(jobsModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(jobsModel)); }
/// <summary/> public async Task UpdateEntity(TEntity entity, bool autoSave = true) { _dbContext.Update(entity); if (autoSave) { await Save(); } }