58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using Common.Dtos.Exper;
|
|
using Hushian.Application.Contracts.Persistence;
|
|
using Hushian.Application.Models;
|
|
using Hushian.Application.Validation;
|
|
using Hushian.Domain.Entites;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Hushian.Application.Services
|
|
{
|
|
public class ExperService
|
|
{
|
|
private readonly IGenericRepository<Company> _CompanyRepository;
|
|
private readonly IGenericRepository<Exper> _ExperRepository;
|
|
public async Task<ResponseBase<bool>> ADDExper(ADD_ExperDto dto,int CompanyID)
|
|
{
|
|
var Response =new ResponseBase<bool>();
|
|
|
|
#region Validation
|
|
bool validate = true;
|
|
var errors = new List<string>();
|
|
|
|
validate = dto.Password.CheckLawPassword(ref errors);
|
|
|
|
#endregion
|
|
|
|
if (validate)
|
|
{
|
|
try
|
|
{
|
|
string UserName = $"E/{CompanyID.ToString("00")}/{_ExperRepository.Get().Count(c => c.CompanyID == CompanyID).ToString("0000")}";
|
|
Response.Success = Response.Value = await _ExperRepository.ADDBool(new Exper()
|
|
{
|
|
CompanyID = CompanyID,
|
|
FullName = dto.FullName,
|
|
Password = dto.Password.GetHash(),
|
|
UserName = UserName
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Errors.Add("خطای سیستمی کد 01");
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
Response.Errors.AddRange(errors);
|
|
}
|
|
|
|
return Response;
|
|
}
|
|
}
|
|
}
|