using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using FrameworkBLL.DocumentSet; using FrameworkDAL.CustomCode.DocumentMap; using FrameworkDAL.CustomCode.DocumentSet; using FrameworkDAL.DTO.DocumentMap; using GB5Shared.DTO.Framework.AutoNumber; using GB5Shared.DTO.Framework.Login; using GB5Shared.GenerateAutoNumber; using GB5Shared.Resource.Response; using GB5Shared.Validation; namespace FrameworkBLL.DocumentMap { public class DocumentMapBLL : IDocumentMapBLL { private readonly IDocumentMapDAL _DocumentMapDAL; private readonly AutoNumber _AutoNumber; private readonly IValidation _Validation; public DocumentMapBLL(IDocumentMapDAL DocumentMapDAL, AutoNumber AutoNumber, IValidation Validation) { _DocumentMapDAL = DocumentMapDAL; _AutoNumber = AutoNumber; _Validation = Validation; } public async Task GetDocumentMap(int EntityId, int BizTransactionClassId, int BizTransactionId, LoginDTO LoginDTO) { try { return await _DocumentMapDAL.GetDocumentMap(EntityId, BizTransactionClassId, BizTransactionId, LoginDTO); } catch (Exception) { throw; } } public async Task GetDocumentSetIdForEntity(int entityId, int bizTransactionTypeId, LoginDTO loginDTO) { try { return await _DocumentMapDAL.GetDocumentSetIdForEntity(entityId, bizTransactionTypeId, loginDTO); } catch (Exception) { throw; } } public async Task SaveDocumentMap(DocumentMapDTO DocumentMapDTO, LoginDTO LoginDTO) { if (DocumentMapDTO == null) throw new ArgumentNullException(nameof(DocumentMapDTO)); try { DocumentMapDTO.DocumentMapModifiedById = LoginDTO.UserId; DocumentMapDTO.DocumentMapModifiedOn = DateTime.UtcNow; if (DocumentMapDTO.DocumentMapId == 0) { DocumentMapDTO.DocumentMapCreatedById = LoginDTO.UserId; DocumentMapDTO.DocumentMapCreatedOn = DateTime.UtcNow; DocumentMapDTO.DocumentMapId = await _DocumentMapDAL.SaveDocumentMap(DocumentMapDTO, LoginDTO); return $"{SuccessResponse.SaveSuccessMessage} {DocumentMapDTO.DocumentMapId}"; } else { await _DocumentMapDAL.UpdateDocumentMap(DocumentMapDTO, LoginDTO); return $"{SuccessResponse.UpdateSuccessMessage} {DocumentMapDTO.DocumentMapId}"; } } catch (ValidationException vex) { throw new Exception(vex.Message); } catch (Exception) { throw; } } public async Task DeleteDocumentMap(int DocumentMapId, LoginDTO LoginDTO) { try { return await _DocumentMapDAL.DeleteDocumentMap(DocumentMapId, LoginDTO); } catch (Exception) { throw; } } } }