public virtual async Task <CustomerDealResponse> FindByIdAsync(string userid, string id, CancellationToken cancellationToken = default(CancellationToken)) { var query = _icustomerDealStore.CustomerDealAll().Where(x => x.Id == id); if (query.Count() == 0) { return(null); } var deal = await query.FirstOrDefaultAsync(cancellationToken); var _shopsInterface = ApplicationContext.Current.Provider.GetRequiredService <IShopsInterface>(); var val = (await _shopsInterface.IsResidentUser(userid, deal.ProjectId)); if (!val.Extension) { return(null); } deal.DepartmentName = _iorganizationExpansionStore.GetFullName(deal.DepartmentId); var phone = new Help.EncDncHelper().Decrypt(deal.CustomerPhone); if (!string.IsNullOrEmpty(phone)) { deal.CustomerPhone = System.Text.RegularExpressions.Regex.Replace(phone, "(\\d{3})\\d{4}(\\d{4})", "$1****$2"); } CustomerDealResponse customerDealResponse = _mapper.Map <CustomerDealResponse>(deal); customerDealResponse.FileList = new List <DealFileItemResponse>(); customerDealResponse.AttachmentList = new List <DealAttachmentResponse>(); if (deal.DealFileInfos != null && deal.DealFileInfos.Count() > 0) { var f = deal.DealFileInfos.Select(a => a.FileGuid).Distinct(); foreach (var item in f) { var f1 = deal.DealFileInfos.Where(a => a.Type != "Attachment" && a.FileGuid == item).ToList(); if (f1?.Count > 0) { customerDealResponse.FileList.Add(ConvertToFileItem(item, f1)); } var f2 = deal.DealFileInfos.Where(a => a.Type == "Attachment" && a.FileGuid == item).ToList(); if (f2?.Count > 0) { customerDealResponse.AttachmentList.AddRange(ConvertToAttachmentItem(f2)); } } } return(customerDealResponse); }
public virtual async Task <CustomerDealResponse> FindByTransactionsIdSaleManAsync(string userid, string id, CancellationToken cancellationToken = default(CancellationToken)) { var query = _icustomerDealStore.CustomerDealAll(); query = query.Where(x => x.FlowId == id && x.Salesman == userid && !x.IsDeleted); var deal = await query.FirstOrDefaultAsync(cancellationToken); if (deal == null) { return(null); } deal.DepartmentName = _iorganizationExpansionStore.GetFullName(deal.DepartmentId); var phone = new Help.EncDncHelper().Decrypt(deal.CustomerPhone); if (!string.IsNullOrEmpty(phone)) { deal.CustomerPhone = System.Text.RegularExpressions.Regex.Replace(phone, "(\\d{3})\\d{4}(\\d{4})", "$1****$2"); } CustomerDealResponse customerDealResponse = _mapper.Map <CustomerDealResponse>(deal); customerDealResponse.FileList = new List <DealFileItemResponse>(); customerDealResponse.AttachmentList = new List <DealAttachmentResponse>(); if (deal.DealFileInfos != null && deal.DealFileInfos.Count() > 0) { var f = deal.DealFileInfos.Select(a => a.FileGuid).Distinct(); foreach (var item in f) { var f1 = deal.DealFileInfos.Where(a => a.Type != "Attachment" && a.FileGuid == item).ToList(); if (f1?.Count > 0) { customerDealResponse.FileList.Add(ConvertToFileItem(item, f1)); } var f2 = deal.DealFileInfos.Where(a => a.Type == "Attachment" && a.FileGuid == item).ToList(); if (f2?.Count > 0) { customerDealResponse.AttachmentList.AddRange(ConvertToAttachmentItem(f2)); } } } return(customerDealResponse); }