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 _CompanyRepository; private readonly IGenericRepository _ExperRepository; public async Task> ADDExper(ADD_ExperDto dto,int CompanyID) { var Response =new ResponseBase(); #region Validation bool validate = true; var errors = new List(); 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; } } }