using FrameworkDAL.CustomCode.Operation; using FrameworkDAL.DTO.Project; using GB5Shared.DTO.Framework.AutoNumber; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.GenerateAutoNumber; using GB5Shared.ResponseStandard; namespace FrameworkBLL.Operation { public class OperationBLL : IOperationBLL { private readonly IOperationDAL _OperationDAL; private readonly AutoNumber _autoNumber; public OperationBLL(IOperationDAL OperationDAL, AutoNumber autoNumber) { _OperationDAL = OperationDAL; _autoNumber = autoNumber; } public async Task GetOperation(int OperationId, LoginDTO LoginDTO) { try { return await _OperationDAL.GetOperation(OperationId, LoginDTO); } catch (Exception) { throw; } } public async Task SaveOperation(OperationDTO OperationDTO, LoginDTO LoginDTO) { try { int initialId = OperationDTO.OperationId; int count = 1 + initialId; if (initialId == 0) { AutoNumberDTO autoNumberDTO = await _autoNumber.GetNumberAsync(count, "OPERATION", LoginDTO); OperationDTO.OperationId = autoNumberDTO.StartNumber; await _OperationDAL.SaveOperation(OperationDTO, LoginDTO); return "Details saved successfully."; } else { await _OperationDAL.UpdateOperation(OperationDTO, LoginDTO); return "Details updated successfully."; } } catch (Exception) { throw; } } public async Task GetSelectListOperation(CriteriaDTO criteriaDTO, LoginDTO loginDTO) { try { return await _OperationDAL.GetSelectListOperation(criteriaDTO, loginDTO); } catch (Exception) { throw; } } public async Task> DeleteOperation(int OperationId, LoginDTO LoginDTO) { try { return await _OperationDAL.DeleteOperation(OperationId, LoginDTO); } catch (Exception) { throw; } } } }