using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using GB5Shared.Resource.Response; using GB5Shared.Validation; using PayRollDAL.DTO.EmployeeReference; using PayRollDAL.Query.EmployeeReference; namespace PayRollDAL.CustomeCode.EmployeeReference { public class EmployeeReferenceDAL : IEmployeeReferenceDAL { private readonly IQueryExecutor _queryExecutor; private readonly Dapr.Client.DaprClient _daprClient; private readonly IValidation _Validation; public EmployeeReferenceDAL(IQueryExecutor queryExecutor, Dapr.Client.DaprClient DaprClient, IValidation IValidation) { _queryExecutor = queryExecutor; _daprClient = DaprClient; _Validation = IValidation; } public async Task SaveEmployeeReference(EmployeeReferenceDTO EmployeeReferenceDTO, LoginDTO LoginDTO) { try { string Sql = EmployeeReferenceQB.SAVE_EMPLOYEEREFERENCE; return await _queryExecutor.ExecuteAsync(LoginDTO, Sql, EmployeeReferenceDTO); } catch (Exception ex) { string Error = await _Validation.HandleException(ex, $"{ErrorResponse.SaveErrorMessage}"); throw new Exception(Error); } } public async Task UpdateEmployeeReference(EmployeeReferenceDTO EmployeeReferenceDTO, LoginDTO LoginDTO) { try { string Sql = EmployeeReferenceQB.UPDATE_EMPLOYEEREFERENCE; return await _queryExecutor.ExecuteAsync(LoginDTO, Sql, EmployeeReferenceDTO); } catch (Exception ex) { string Error = await _Validation.HandleException(ex, $"{ErrorResponse.UpdateErrorMessage}"); throw new Exception(Error); } } public async Task DeleteEmployeeReference(int EmployeeId, LoginDTO LoginDTO) { try { string Sql = EmployeeReferenceQB.DELETE_EMPLOYEEREFERENCE; var Parameters = new { employeeid = EmployeeId }; int result = await _queryExecutor.ExecuteAsync(LoginDTO, Sql, Parameters); if (result > 0) { return $"{SuccessResponse.DeleteSuccessMessage}"; } else { return $"{ErrorResponse.DeleteNotFoundMessage}"; } } catch (Exception ex) { string Error = await _Validation.HandleException(ex, $"{ErrorResponse.DeleteErrorMessage}"); throw new Exception(Error); } } } }