private static async Task SearchTrim(IMessageActivity replyMessage, string pi_Trim) { char[] charsToTrim = { ' ', '\r' }; pi_Trim = pi_Trim.Trim(charsToTrim); pi_Trim = pi_Trim.Replace(" ", string.Empty); ApparelTrim l_trim = await new TrimHelper().TrimSearch(pi_Trim); if (l_trim != null) { replyMessage.Text = l_trim.apparelTrimID; //button var actions = new List <CardAction>(); actions.Add(new CardAction { Title = $"View Image", Value = l_trim.imageURL, Type = ActionTypes.OpenUrl, Image = l_trim.imageURL }); //attachment layout style //replyMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel; replyMessage.Attachments.Add(new HeroCard { Title = l_trim.apparelTrimID, Subtitle = l_trim.apparelTrimNo, Text = string.Join(" ", l_trim.longDescriptions), Images = new List <CardImage> { new CardImage { Url = l_trim.imageURL, Alt = l_trim.apparelTrimID } } , Buttons = actions }.ToAttachment()); } else { replyMessage.Text = $"sorry , the trim [ { pi_Trim } ] can not found."; } }
public async Task <ApparelTrim> TrimSearch(string pi_TrimNo) { ApparelTrim l_returnValue = null; string l_APIUrl = Common.ConfigHelper.GetConfigValue("LPD-TrimSearchAPIUrl"); try { if (!string.IsNullOrEmpty(l_APIUrl) && !string.IsNullOrEmpty(pi_TrimNo)) { #region search entity var requestEntity = new Model.SelectionFilter() { FilterType = Model.SelectionFilter.FilterTypeLeaf, Filters = new Model.SelectionFilter[] { }, AttributeName = "item_number", FilterValue = pi_TrimNo }; #endregion string l_returnjson = await new Common.HttpClientHelper().HttpClient_PostAsync(l_APIUrl, JsonConvert.SerializeObject(requestEntity).ToString()); BaseResponse <List <PagingData <ApparelTrim> > > l_returnEntity = await JsonConvert.DeserializeObjectAsync <BaseResponse <List <PagingData <ApparelTrim> > > >(l_returnjson); #region get style entity if (l_returnEntity != null) { if (l_returnEntity.results != null && l_returnEntity.results.Count > 0) { if (l_returnEntity.results.First().data != null && l_returnEntity.results.First().data.Count() > 0) { l_returnValue = l_returnEntity.results.First().data.First(); } } } #endregion } } catch (Exception ex) { } return(l_returnValue); }