public IList <DocumentTypeModel> GetDocumentType(NTAEnum.eModule module, NTAEnum.eDocumentModule documentModule = NTAEnum.eDocumentModule.None) { var query = _docTypeRepository.Table.Where(x => x.ModuleId == (int)module); if (documentModule != NTAEnum.eDocumentModule.None) { string docModule = Enum.GetName(typeof(NTAEnum.eDocumentModule), documentModule); query = query.Where(x => x.DataModule == docModule).OrderBy(x => x.DisplayOrder); } var list = AutomapperConfig.Mapper.Map <IList <DocumentTypeModel> >(query); list.Insert(0, new DocumentTypeModel { Id = 0, DisplayName = "None" }); return(list); }
public async Task <DocumentFileModel> GetFileAsync(int fileId, NTAEnum.eModule module) { return(await Task.Factory.StartNew <DocumentFileModel>(() => { var model = new DocumentFileModel(); if (Common.GetClientModule.Any(x => x == module)) { var document = _customerDocumentRepository.Table.Where(x => x.Id == fileId); if (document.Any()) { model = document.Select(x => new DocumentFileModel { DataId = x.DataId, Name = x.DocumentType.DisplayName, MimeType = x.FileMimeType, FileData = x.FileBinary }).FirstOrDefault(); } return model; } else { var document = _hrDocumentRepository.Table.Where(x => x.Id == fileId); if (document.Any()) { model = document.Select(x => new DocumentFileModel { DataId = x.DataId, Name = x.DocumentType.DisplayName, MimeType = x.FileMimeType, FileData = x.FileBinary }).FirstOrDefault(); } return model; } })); }
public IList <DocumentFileMetaDataModel> GetFileMetaData(int fileId, int masterId, int dataId, NTAEnum.eDocumentType docType, NTAEnum.eModule module) { var documentType = _docTypeRepository.GetById((int)docType); if (Common.GetClientModule.Any(x => x == module)) { var doc = _customerDocumentRepository.Table; if (fileId > 0) { doc = doc.Where(x => x.Id == fileId); } if (dataId > 0) { doc = doc.Where(x => x.DataId == dataId && x.DocumentTypeId == (int)docType); } var model = new List <DocumentFileMetaDataModel>(); if (doc.Any()) { model = doc.Select(x => new DocumentFileMetaDataModel { FileId = x.Id, MasterId = x.DataId, DataId = x.DataId, FileName = x.FileName, MimeType = x.FileMimeType, Name = documentType.DisplayName, Remarks = "", Module = (int)module }).ToList(); } return(model); } else { var doc = _hrDocumentRepository.Table; if (fileId > 0) { doc = doc.Where(x => x.Id == fileId); } if (masterId > 0) { doc = doc.Where(x => x.MasterId == masterId && x.DocumentTypeId == (int)docType); } if (dataId > 0) { doc = doc.Where(x => x.DataId == dataId && x.DocumentTypeId == (int)docType); } var model = new List <DocumentFileMetaDataModel>(); if (doc.Any()) { model = doc.Select(x => new DocumentFileMetaDataModel { FileId = x.Id, MasterId = x.MasterId, DataId = x.DataId, FileName = x.FileName, MimeType = x.FileMimeType, Name = documentType.DisplayName, Remarks = x.Remarks, Module = (int)module }).ToList(); } return(model); } }