public async Task <IViewComponentResult> InvokeAsync(ViewComponentVModel model) { try { var userTrackingLKDId = (await _lookupAppService.GetAllLookDetail(null, model.Module)).Items.FirstOrDefault().Id; var businessDocumentList = (await _documentAppService.GetAllBusinessDocuments(null, userTrackingLKDId, null)).Items.ToList(); foreach (var businessDoc in businessDocumentList) { businessDoc.BusinessDocumentAttachmentDto = _documentAppService.GetAllBusinessDocumentAttachments(null, businessDoc.Id, model.BusinessEntityId).Result.Items.ToList(); } var documentModel = new DocumentUploaderViewModel() { BusinessEntityId = model.BusinessEntityId, DocumentList = businessDocumentList, IsReadOnly = model.IsReadOnly }; return(View(documentModel)); } catch (Exception ex) { throw ex; } }
public PagedResultDto <PhotoTrackingListDto> GetAllPhotoTrackingPagedResult(PagedResultRequestExtDto input, int?documentTypeId = null) { var queryable = GetAllPhotoTrackingIQueryable(input); ////Server Side Pagging ////var count = queryable.Count(); ////var result = queryable.Skip((input.SkipCount)).Take(input.MaxResultCount); var list = queryable.OrderByDescending(x => x.CreationTime); var photoTrackingList = ObjectMapper.Map <IReadOnlyList <PhotoTrackingListDto> >(list).ToList(); var photoTrackingLKDId = _lookupAppService.GetAllLookDetail(null, LookUpDetailConst.PhotoTracking).Result.Items.First().Id; var businessDocumentList = _documentAppService.GetAllBusinessDocuments(null, photoTrackingLKDId, documentTypeId).Result.Items; for (int i = 0; i < photoTrackingList.Count; i++) { var attachmentCount = _documentAppService.GetAllBusinessDocumentAttachments(null, null, photoTrackingList[i].Id).Result.Items.Count; if (attachmentCount == 0)//Soft Delete Photo Tracking { _photoTrackingRepository.Delete(photoTrackingList[i].Id); photoTrackingList.Remove(photoTrackingList[i]); continue; } var bizDocList = new List <BusinessDocumentDto>(); foreach (var businessDoc in businessDocumentList) { var businessDocument = new BusinessDocumentDto() { AllowMultiple = businessDoc.AllowMultiple, BusinessEntityLKDId = businessDoc.BusinessEntityLKDId, DocumentType = businessDoc.DocumentType, DocumentTypeId = businessDoc.DocumentTypeId, Id = businessDoc.Id, IsRequired = businessDoc.IsRequired }; businessDocument.BusinessDocumentAttachmentDto = _documentAppService.GetAllBusinessDocumentAttachments(null, businessDoc.Id, photoTrackingList[i].Id).Result.Items.ToList(); bizDocList.Add(businessDocument); } photoTrackingList[i].DocumentList = bizDocList; } var data = new PagedResultDto <PhotoTrackingListDto>(photoTrackingList.Count(), photoTrackingList); return(data); }
public async Task <EditPersonalDetailViewModel> LoadPersonalDetail(string userIdEnyc) { var userId = Convert.ToInt64(CryptoEngine.DecryptString(userIdEnyc)); var user = await _userAppService.GetAsync(new EntityDto <long>(userId)); var genderMasterId = (await _lookupAppService.GetAllLookUpMaster(null, "Gender")).Items.FirstOrDefault().Id; var genderSelectListItems = (await _lookupAppService.GetLookDetailComboboxItems(genderMasterId)).Items .Select(p => p.ToSelectListItem()) .ToList(); genderSelectListItems.Find(x => x.Value == user.Gender.ToString()).Selected = true; var personalDetailLKDId = (await _lookupAppService.GetAllLookDetail(null, LookUpDetailConst.PersonalDetail)).Items.FirstOrDefault().Id; var businessDocumentList = (await _documentAppService.GetAllBusinessDocuments(null, personalDetailLKDId, null)).Items.ToList(); foreach (var businessDoc in businessDocumentList) { if (businessDoc.BusinessEntityLKDId == personalDetailLKDId) { var photo = new List <BusinessDocumentAttachmentDto>(); photo.Add(_documentAppService.GetAllBusinessDocumentAttachments(null, businessDoc.Id, (int)userId).Result.Items.FirstOrDefault()); businessDoc.BusinessDocumentAttachmentDto = photo; } } var documentModel = new DocumentUploaderViewModel() { BusinessEntityId = userId, DocumentList = businessDocumentList }; return(new EditPersonalDetailViewModel { User = user, Gender = genderSelectListItems, ProfilePhoto = documentModel }); }
public async Task <AjaxResponse> Upload(UploadVModel model) { if (ModelState.IsValid) { string profilePhotoPath = string.Empty; string fileUrl = UploadedFile(model, out profilePhotoPath); if (!string.IsNullOrEmpty(fileUrl)) { //Delete Old if (model.IsDeleteOld) { var oldAttachmentList = (await _documentAppService.GetAllBusinessDocumentAttachments(null, model.BusinessDocumentId, model.BusinessEntityId)).Items; foreach (var oldAttachment in oldAttachmentList) { await _documentAppService.DeleteBusinessDocumentAttachment(new BusinessDocumentAttachmentDto() { Id = oldAttachment.Id }); } } var businessDocumentAttachmentDto = new BusinessDocumentAttachmentDto() { BusinessDocumentId = model.BusinessDocumentId, BusinessEntityId = model.BusinessEntityId, FilePath = fileUrl, FileName = System.IO.Path.GetFileNameWithoutExtension(model.Image.FileName), FileExt = System.IO.Path.GetExtension(model.Image.FileName), Order = 0 }; var attachment = await _documentAppService.CreateBusinessDocumentAttachment(businessDocumentAttachmentDto); if (attachment.Id > 0) { if (!string.IsNullOrEmpty(profilePhotoPath))//Profile Photo { ChangeProfilePhotoDto changeProfilePhotoDto = new ChangeProfilePhotoDto() { Id = model.BusinessEntityId, ProfilePhotoPath = businessDocumentAttachmentDto.Id.ToString() }; await _userAppService.UpdateProfilePhoto(changeProfilePhotoDto); } return(new AjaxResponse() { Success = true, Result = attachment }); } else { return(new AjaxResponse(new ErrorInfo() { Message = "AttachmentNotAdded" })); } } } return(new AjaxResponse(new ErrorInfo() { Message = "Errors" })); }