using FrameworkDAL.CustomCode.Region; using FrameworkDAL.CustomCode.RegionType; using FrameworkDAL.DTO.Region; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.ResponseStandard; using GB5Shared.GenerateAutoNumber; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using GB5Shared.DTO.Framework.AutoNumber; namespace FrameworkBLL.RegionType { public class RegionTypeBLL : IRegionTypeBLL { private readonly IRegionTypeDAL _RegionTypeDAL; private readonly AutoNumber _autoNumber; public RegionTypeBLL(IRegionTypeDAL IRegionTypeDAL, AutoNumber autoNumber) { _RegionTypeDAL = IRegionTypeDAL; _autoNumber = autoNumber; } public async Task GetSelectListRegionType(CriteriaDTO criteriaDTO, LoginDTO loginDTO) { try { return await _RegionTypeDAL.GetSelectListRegionType(criteriaDTO, loginDTO); } catch (Exception) { throw; } } public async Task GetRegionType(int RegionTypeId, LoginDTO LoginDTO) { try { return await _RegionTypeDAL.GetRegionType(RegionTypeId, LoginDTO); } catch (Exception) { throw; } } public async Task SaveRegionType(RegionTypeDTO RegionTypeDTO, LoginDTO LoginDTO) { try { int initialId = RegionTypeDTO.RegionTypeId; int count = 1 + initialId; if (initialId == 0) { AutoNumberDTO autoNumberDTO = await _autoNumber.GetNumberAsync(count, "REGIONTYPE", LoginDTO); RegionTypeDTO.RegionTypeId = autoNumberDTO.StartNumber; await _RegionTypeDAL.SaveRegionType(RegionTypeDTO, LoginDTO); return "Region Type details saved successfully."; } else { await _RegionTypeDAL.UpdateRegionType(RegionTypeDTO, LoginDTO); return "Region Type details updated successfully."; } } catch (Exception) { throw; } } public async Task DeleteRegionType(int RegionTypeId, LoginDTO LoginDTO) { try { return await _RegionTypeDAL.DeleteRegionType(RegionTypeId, LoginDTO); } catch (Exception) { throw; } } } }