|
@@ -120,6 +120,7 @@ namespace MTWorkHR.Application.Services
|
|
response.ProfileImage = file;
|
|
response.ProfileImage = file;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ attach.Content = new byte[0];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -162,6 +163,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var query = _userManager.Users
|
|
var query = _userManager.Users
|
|
.Include(u => u.Qualification).Include(u => u.JobTitle).Include(u => u.University).Include(u => u.Industry).Include(u => u.Country)
|
|
.Include(u => u.Qualification).Include(u => u.JobTitle).Include(u => u.University).Include(u => u.Industry).Include(u => u.Country)
|
|
|
|
+ .Where(e => _globalInfo.CompanyId == null || e.CompanyId != _globalInfo.CompanyId)
|
|
.AsQueryable();
|
|
.AsQueryable();
|
|
|
|
|
|
if (PagingInputDto.Filter != null)
|
|
if (PagingInputDto.Filter != null)
|
|
@@ -173,6 +175,7 @@ namespace MTWorkHR.Application.Services
|
|
u.FirstName.Contains(filter) ||
|
|
u.FirstName.Contains(filter) ||
|
|
u.LastName.Contains(filter) ||
|
|
u.LastName.Contains(filter) ||
|
|
u.FavoriteName.Contains(filter) ||
|
|
u.FavoriteName.Contains(filter) ||
|
|
|
|
+ u.Position.Contains(filter) ||
|
|
u.PhoneNumber.Contains(filter));
|
|
u.PhoneNumber.Contains(filter));
|
|
}
|
|
}
|
|
if (PagingInputDto.IndustryId != null)
|
|
if (PagingInputDto.IndustryId != null)
|
|
@@ -195,6 +198,18 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
query = query.Where(u => u.CountryId == PagingInputDto.CountryId);
|
|
query = query.Where(u => u.CountryId == PagingInputDto.CountryId);
|
|
}
|
|
}
|
|
|
|
+ if (PagingInputDto.UserTypeId != null)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.UserType == PagingInputDto.UserTypeId);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.Employed != null && PagingInputDto.Employed == true)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.CompanyId != null);
|
|
|
|
+ }
|
|
|
|
+ if (PagingInputDto.Employed != null && PagingInputDto.Employed == false)
|
|
|
|
+ {
|
|
|
|
+ query = query.Where(u => u.CompanyId == null);
|
|
|
|
+ }
|
|
|
|
|
|
var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
|
|
var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
|
|
|
|
|
|
@@ -229,7 +244,7 @@ namespace MTWorkHR.Application.Services
|
|
public async Task<List<UserAllDto>> GetAllCompanyEmployees()
|
|
public async Task<List<UserAllDto>> GetAllCompanyEmployees()
|
|
{
|
|
{
|
|
var employees = await _userManager.GetUsersInRoleAsync("Employee");
|
|
var employees = await _userManager.GetUsersInRoleAsync("Employee");
|
|
- var res = employees.Where(e => _globalInfo.CompanyId == null || e.CompanyId == _globalInfo.CompanyId).ToList();
|
|
|
|
|
|
+ var res = employees.Where(e => e.CompanyId == _globalInfo.CompanyId).ToList();
|
|
var response = MapperObject.Mapper.Map<List<UserAllDto>>(res);
|
|
var response = MapperObject.Mapper.Map<List<UserAllDto>>(res);
|
|
|
|
|
|
return response;
|
|
return response;
|
|
@@ -251,15 +266,15 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var emailExists = await _userManager.FindByEmailAsync(input.Email);
|
|
var emailExists = await _userManager.FindByEmailAsync(input.Email);
|
|
if (emailExists != null)
|
|
if (emailExists != null)
|
|
- throw new AppException(ExceptionEnum.RecordAlreadyExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.RecordEmailAlreadyExist);
|
|
|
|
|
|
var phoneExists = await _userManager.FindByAnyAsync(input.PhoneNumber);
|
|
var phoneExists = await _userManager.FindByAnyAsync(input.PhoneNumber);
|
|
if (phoneExists != null)
|
|
if (phoneExists != null)
|
|
- throw new AppException(ExceptionEnum.RecordAlreadyExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.RecordPhoneAlreadyExist);
|
|
|
|
|
|
var userExists = await _userManager.FindByAnyAsync(input.UserName);
|
|
var userExists = await _userManager.FindByAnyAsync(input.UserName);
|
|
if (userExists != null)
|
|
if (userExists != null)
|
|
- throw new AppException(ExceptionEnum.RecordAlreadyExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.RecordNameAlreadyExist);
|
|
//loop for given list of attachment, and move each file from Temp path to Actual path
|
|
//loop for given list of attachment, and move each file from Temp path to Actual path
|
|
// _fileService.UploadFiles(files);
|
|
// _fileService.UploadFiles(files);
|
|
if (input.UserAttachments == null )
|
|
if (input.UserAttachments == null )
|
|
@@ -377,7 +392,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var user = await _userManager.FindByIdAsync(input.UserId);
|
|
var user = await _userManager.FindByIdAsync(input.UserId);
|
|
if (user == null)
|
|
if (user == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
var result = await _userManager.ConfirmEmailAsync(user, input.Token);
|
|
var result = await _userManager.ConfirmEmailAsync(user, input.Token);
|
|
return result.Succeeded;
|
|
return result.Succeeded;
|
|
}
|
|
}
|
|
@@ -385,7 +400,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(userId));
|
|
var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(userId));
|
|
if (user == null)
|
|
if (user == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
|
|
|
|
string code = await _userManager.GeneratePasswordResetTokenAsync(user);
|
|
string code = await _userManager.GeneratePasswordResetTokenAsync(user);
|
|
var route = "auth/ConfirmEmail";
|
|
var route = "auth/ConfirmEmail";
|
|
@@ -400,7 +415,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(userId));
|
|
var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(userId));
|
|
if (user == null)
|
|
if (user == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
|
|
|
|
string token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
|
string token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
|
string codeHtmlVersion = HttpUtility.UrlEncode(token);
|
|
string codeHtmlVersion = HttpUtility.UrlEncode(token);
|
|
@@ -420,7 +435,7 @@ namespace MTWorkHR.Application.Services
|
|
var entity = _userManager.Users.Include(x => x.UserAttachments).FirstOrDefault(x=> x.Id == input.Id);
|
|
var entity = _userManager.Users.Include(x => x.UserAttachments).FirstOrDefault(x=> x.Id == input.Id);
|
|
|
|
|
|
if (entity == null)
|
|
if (entity == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
if (input.UserAttachments == null)
|
|
if (input.UserAttachments == null)
|
|
input.UserAttachments = new List<AttachmentDto>();
|
|
input.UserAttachments = new List<AttachmentDto>();
|
|
var oldAttachList = entity.UserAttachments;
|
|
var oldAttachList = entity.UserAttachments;
|
|
@@ -510,7 +525,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
|
|
if (user == null)
|
|
if (user == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
var purpose = UserManager<ApplicationUser>.ResetPasswordTokenPurpose;
|
|
var purpose = UserManager<ApplicationUser>.ResetPasswordTokenPurpose;
|
|
var result = await _userManager.VerifyUserTokenAsync(user, "Default", purpose, input.Token);
|
|
var result = await _userManager.VerifyUserTokenAsync(user, "Default", purpose, input.Token);
|
|
return !result;
|
|
return !result;
|
|
@@ -521,7 +536,7 @@ namespace MTWorkHR.Application.Services
|
|
var user = await _userManager.FindByIdAsync(_globalInfo.UserId);
|
|
var user = await _userManager.FindByIdAsync(_globalInfo.UserId);
|
|
|
|
|
|
if (user == null)
|
|
if (user == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
|
|
|
|
if (!await _userManager.CheckPasswordAsync(user, input.OldPassword))
|
|
if (!await _userManager.CheckPasswordAsync(user, input.OldPassword))
|
|
throw new AppException(ExceptionEnum.WrongCredentials);
|
|
throw new AppException(ExceptionEnum.WrongCredentials);
|
|
@@ -547,7 +562,7 @@ namespace MTWorkHR.Application.Services
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public async Task<bool> VerifyOTP(VerifyOTPDto input)
|
|
public async Task<bool> VerifyOTP(VerifyOTPDto input)
|
|
@@ -560,7 +575,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
|
|
if (user == null)
|
|
if (user == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
|
|
|
|
string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user);
|
|
string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user);
|
|
|
|
|
|
@@ -582,7 +597,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
|
|
var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
|
|
if (entity == null)
|
|
if (entity == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
if (!entity.IsStopped)
|
|
if (!entity.IsStopped)
|
|
{
|
|
{
|
|
entity.IsStopped = true;
|
|
entity.IsStopped = true;
|
|
@@ -593,7 +608,7 @@ namespace MTWorkHR.Application.Services
|
|
{
|
|
{
|
|
var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
|
|
var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
|
|
if (entity == null)
|
|
if (entity == null)
|
|
- throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
|
|
|
+ throw new AppException(ExceptionEnum.UserNotExist);
|
|
|
|
|
|
entity.IsStopped = false;
|
|
entity.IsStopped = false;
|
|
entity.AccessFailedCount = 0;
|
|
entity.AccessFailedCount = 0;
|