public IActionResult OneTimeChangepassword([FromQuery] int id, [FromQuery] string password) { try { // _context.Attach(user); User exist = _context.Set <User>().Find(id); exist.Password = password; _context.SaveChanges(); // RedirectToAction("Login"); return(Ok(new { status = true, Msg = "Password Changed Successfully!" })); } catch (Exception ex) { _ErrLogService.Log(ex, HttpContext); return(StatusCode(500, new { status = true, Msg = ex.Message })); } }
public async Task <IActionResult> ChangePassword([FromQuery] int id, [FromBody] User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { // _context.Attach(user); User exist = await _context.Set <User>().FindAsync(id); exist.Password = user.Password; await _context.SaveChangesAsync(); return(Ok(new { status = true, Msg = "Password Changed Successfully!" })); } catch (Exception ex) { _ErrLogService.Log(ex, HttpContext); return(StatusCode(500, new { status = true, Msg = ex.Message })); } }
public async Task <IActionResult> UpdateUserCorporates([FromQuery] int id, [FromBody] List <UserCorporate> userCorporate) { // Update User Corporate if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { for (int i = 0; i < userCorporate.Count; i++) { userCorporate[i].ModifiedBy = id; userCorporate[i].ModifiedOn = DateTime.Now; } var user = _context.User.Include(x => x.lstUserCorporate).SingleOrDefault(x => x.Id == id); user.lstUserCorporate = userCorporate; User existUser = await _context.Set <User>().FindAsync(id); if (existUser != null) { _context.Entry(existUser).CurrentValues.SetValues(user); await _context.SaveChangesAsync(); return(StatusCode(200, new { status = true, Msg = "Record Updated!" })); } else { return(StatusCode(200, new { status = false, Msg = "User Not Found!" })); } } catch (Exception ex) { _ErrLogService.Log(ex, HttpContext); return(StatusCode(500, new { status = true, Msg = "Internal Server Error.", MsgDetails = ex.Message })); } }