using FrameworkDAL.CustomCode.UOM; using FrameworkDAL.DTO.UOM; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.GenerateAutoNumber; using GB5Shared.DTO.Framework.AutoNumber; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FrameworkBLL.UOM { public class UOMBLL : IUOMBLL { private readonly IUOMDAL _UOMDAL; private readonly AutoNumber _AutoNumber; public UOMBLL(IUOMDAL IUOMDAL, AutoNumber AutoNumber) { _UOMDAL = IUOMDAL; _AutoNumber = AutoNumber; } public async Task GetUOM(int UOMId, LoginDTO LoginDTO) { try { return await _UOMDAL.GetUOM(UOMId, LoginDTO); } catch (Exception) { throw; } } public async Task GetSelectionListUOM(CriteriaDTO criteriaDTO, LoginDTO loginDTO) { try { return await _UOMDAL.GetSelectionListUOM(criteriaDTO, loginDTO); } catch (Exception) { throw; } } public async Task SaveUOM(UOMDTO UOMDTO, LoginDTO LoginDTO) { try { int InitialId = UOMDTO.UOMId; int count = 1 + InitialId; if (InitialId == 0) { AutoNumberDTO AutoNumberDTO = await _AutoNumber.GetNumberAsync(count, "LOV", LoginDTO); UOMDTO.UOMId = AutoNumberDTO.StartNumber; await _UOMDAL.SaveUOM(UOMDTO, LoginDTO); return $"Details saved successfully with UOM Id {UOMDTO.UOMId}."; } else { await _UOMDAL.UpdateUOM(UOMDTO, LoginDTO); return $"Details updated successfully with UOM Id {UOMDTO.UOMId}."; } } catch (Exception) { throw; } } public async Task DeleteUOM(int UOMId, LoginDTO LoginDTO) { try { return await _UOMDAL.DeleteUOM(UOMId, LoginDTO); } catch (Exception) { throw; } } } }