public async Task <TokenResponseDto> CreateAccountAsync(RegisterDto registerDto) { try { PasswordHashing(out byte[] hash, out byte[] salt, registerDto.Password); Account account = new Account { Email = registerDto.Email, RoleId = (int)registerDto.RoleId, PasswordHash = hash, PasswordSalt = salt }; await _accountRepo.CreateAsync(account); return(new TokenResponseDto { Token = _jwtHelper.GenerateToken(registerDto.Email), Code = System.Net.HttpStatusCode.OK }); } catch (System.Exception e) { return(new TokenResponseDto { Error = e.Message, }); } }
public async Task <IActionResult> UpdateUserShift([FromBody] UpdateUserDto updatedUser) { var newUser = new User { UserId = updatedUser.UserId, AccountId = updatedUser.AccountId, FirstName = updatedUser.FirstName, LastName = updatedUser.LastName, Gender = updatedUser.Gender, DepartmentId = updatedUser.DepartmentId, PositionId = updatedUser.PositionId }; await _userShiftRepo.DeleteAsync(d => d.UserId == updatedUser.UserId); await _userRepo.UpdateAsync(newUser); if (updatedUser.UserShifts.Count > 0) { foreach (var userShift in updatedUser.UserShifts) { var newUserShift = new UserShift { ShiftId = userShift.ShiftId, UserId = userShift.UserId, Day = userShift.Day }; await _userShiftRepo.CreateAsync(newUserShift); } } return(Ok(await GetUserList())); }
public async Task <IActionResult> AddLeaveInfo([FromBody] LeaveRequest leave) { await _leaveReqRepo.CreateAsync(leave); var leavesInDb = await GetLeaveList(); return(Ok(leavesInDb)); }
public async Task <IActionResult> AddUserInfo([FromBody] User user) { await _userRepo.CreateAsync(user); var usersInDb = await GetUserList(); return(Ok(usersInDb)); }