public async Task <GridModel <ProductPrice> > GetListPricePG(RequestParams pr) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPriceGetListPricePg + "/" + pr.PageIndex.ToString() + "/" + pr.ProductId.ToString() + "/" + pr.ProductCategoryId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); GridModel <ProductPrice> listPrice = new GridModel <ProductPrice>(); if (responseData.Code == 200) { listPrice = Helpers.Deserialize <GridModel <ProductPrice> >(responseData.Data); } return(listPrice); }
public async Task <List <Product> > GetListProduct(int productCategoryId, int organizationId) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogGetListProduct + "/" + productCategoryId.ToString() + "/" + organizationId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200) { return(Helpers.Deserialize <List <Product> >(responseData.Data)); } return(new List <Product>()); }
public async Task <Organization> GetInforOrganizationFromAcc(int accountId) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogGetInforOrganizationFromAcc + "/" + accountId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200) { return(Helpers.Deserialize <Organization>(responseData.Data)); } return(new Organization() { OrganizationId = -1 }); }
public async Task <ActionResult> Add(Organization ogt) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_AddOrganization, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, FormValue = Helpers.ConvertObToKeyPair(ogt) }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code == 200) { SystemSession.CurrentAccount.OrganizationName = ogt.OrganizationId != 0 ? ogt.Name : OrganizationName; return(RedirectToAction("Index", "Organization")); } else { ModelState.AddModelError("", responseData.Message); } return(View("_Add", ogt)); }
// GET: Product public async Task <ActionResult> Index() { // Get list ProductCategory RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_GetListProductCategory, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code != 200) { ViewBag.ResultData = null; if (responseData.Code == 401) { ViewBag.ResultMessage = responseData.Message; } } else { ViewBag.ResultData = Helpers.Deserialize <List <ProductCategory> >(responseData.Data); } return(View()); }
public async Task <ActionResult> LoadContent(int productCategoryId, int pageIndex) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_GetListByConditional + "/" + pageIndex.ToString() + "/" + productCategoryId.ToString() + "/" + OrganizationId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, }; GridModel <Product> listProduct = new GridModel <Product>(); if (productCategoryId > 0) { var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code != 200) { ViewBag.ResultData = null; return(View("index")); } listProduct = Helpers.Deserialize <GridModel <Product> >(responseData.Data); } return(PartialView("_Content", listProduct)); }
public async Task <GridModel <Product> > GetListProductPG(RequestParams pr) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogGetListProductPg + "/" + pr.PageIndex.ToString() + "/" + pr.ProductCategoryId.ToString() + "/" + pr.OrganizationId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); GridModel <Product> listProduct = new GridModel <Product>(); if (responseData.Code == 200) { listProduct = Helpers.Deserialize <GridModel <Product> >(responseData.Data); string listProductString = Helpers.Serialize(listProduct.Data); requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPriceGetPriceFromProduct, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken }, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("listProductString", listProductString) } }; responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); var listProductPrice = new List <Product>(); var oldListProduct = listProduct.Data; var newListProduct = new List <Product>(); if (responseData.Code == 200) { listProductPrice = Helpers.Deserialize <List <Product> >(responseData.Data); foreach (var item in oldListProduct) { item.Price = listProductPrice.FirstOrDefault(x => x.ProductId == item.ProductId).Price; newListProduct.Add(item); } listProduct.Data = newListProduct; } } return(listProduct); }
public async Task <PartialViewResult> ShopCart(List <Cart> cart) { if (SystemSession.ShopCart != null && SystemSession.ShopCart.Count > 0) { PaymentModel payment = new PaymentModel() { Payment = new Payment() { AccountId = SystemSession.CurrentAccount.AccountId, PaymentCode = Helpers.RandomString(8, false) }, ListPaymentDetail = SystemSession.ShopCart }; string paymentString = Helpers.Serialize(payment); RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Shop_Payment, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("paymentString", paymentString) } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code == 200) { SystemSession.ShopCart = null; } } return(PartialView("_Cart", cart)); }
public static async Task <ResponseData> GetToken(RequestInfor requestInfor) { ResponseData responseData = new ResponseData(); try { using (var client = new HttpClient { BaseAddress = new Uri(requestInfor.UrlBase) }) { string creds = String.Format("{0}:{1}", requestInfor.HeaderValue.SecretUser, requestInfor.HeaderValue.SecretPass); byte[] bytes = Encoding.ASCII.GetBytes(creds); var header = new AuthenticationHeaderValue(requestInfor.HeaderValue.AuthorizationType, Convert.ToBase64String(bytes)); client.DefaultRequestHeaders.Authorization = header; var request = await client.PostAsync("Token", new FormUrlEncodedContent(requestInfor.FormValue)); if (request.StatusCode == HttpStatusCode.OK) { var jToken = Helpers.Deserialize <AuthenticationToken>(request.Content.ReadAsStringAsync().Result); responseData = new ResponseData() { Code = (int)HttpStatusCode.OK, Data = jToken.access_token, Message = "Get access_token successful!" }; } else { var errorData = Helpers.Deserialize <ErrorData>(request.Content.ReadAsStringAsync().Result); responseData = new ResponseData() { Code = (int)request.StatusCode, Message = errorData.error_description//errorData.error + " - " + }; } } } catch (Exception e) { responseData = new ResponseData() { Code = 0, Message = "Hệ thống đang bảo trì hoặc gặp sự cố kỹ thuật, xin vui lòng quay lại sau! => " + e.Message }; // Write log file } return(responseData); }
public async Task Payment(string paymentString) { RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPaymentPayment, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("paymentString", paymentString) } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); }
public async Task Delete(int productId) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_Delete + "/" + productId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.DELETE); }
public async Task <Account> GetInforAccount(string email) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_GetInforAccount + "/" + email }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200) { return(Helpers.Deserialize <Account>(responseData.Data)); } return(new Account()); }
public async Task <List <ProductCategory> > GetListProductCategory() { RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogGetListProductCategory }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200) { return(Helpers.Deserialize <List <ProductCategory> >(responseData.Data)); } return(new List <ProductCategory>()); }
public async Task <PartialViewResult> UpdatePrice(ProductPriceModel model) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_UpdatePrice, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, FormValue = Helpers.ConvertObToKeyPair(model.ProductPrice) }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); return(PartialView("_UpdatePrice", model)); }
public async Task <GridModel <Payment> > ViewHistory(RequestParams pr) { RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPaymentViewHistory + "/" + pr.PageIndex.ToString() + "/" + pr.AccountId.ToString() }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); var listHistory = new GridModel <Payment>(); if (responseData.Code == 200) { listHistory = Helpers.Deserialize <GridModel <Payment> >(responseData.Data); } return(listHistory); }
public async Task DeleteProduct(int productId) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogDeleteProduct + "/" + productId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.DELETE); }
public async Task <GridModel <Product> > Shop_GetListProductPrice(RequestParams pr) { RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPriceShopGetListProductPrice + "/" + pr.PageIndex.ToString() + "/" + pr.ProductCategoryId.ToString() }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); GridModel <Product> listProductModel = new GridModel <Product>(); if (responseData.Code == 200) { listProductModel = Helpers.Deserialize <GridModel <Product> >(responseData.Data); string listProductString = Helpers.Serialize(listProductModel.Data); requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogShopGetListProduct, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("listProductString", listProductString) } }; responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code == 200) { var listProductResult = Helpers.Deserialize <List <Product> >(responseData.Data); var newListProduct = new List <Product>(); foreach (var item in listProductResult) { item.Price = listProductModel.Data.First(x => x.ProductId == item.ProductId).Price; item.Date = listProductModel.Data.First(x => x.ProductId == item.ProductId).Date; newListProduct.Add(item); } listProductModel.Data = newListProduct; } } return(listProductModel); }
public void AddOrganization(Organization ogt) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogAddOrganization, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken }, FormValue = Helpers.ConvertObToKeyPair(ogt) }; var responseData = ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); }
public async Task UpdatePrice(ProductPrice productPrice) { if (Request.Headers.TryGetValue("Authorization", out _authorizationToken)) { this._accessToken = _authorizationToken.ToString().Substring("Bearer ".Length); } RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPriceUpdatePrice, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = _accessToken }, FormValue = Helpers.ConvertObToKeyPair(productPrice) }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); }
public async Task <ActionResult> LoadContent(int productCategoryId, int pageIndex) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Shop_GetListProductPrice + "/" + pageIndex.ToString() + "/" + productCategoryId.ToString() }; GridModel <Product> listProduct = new GridModel <Product>(); var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code != 200) { ViewBag.ResultData = null; return(View("index")); } listProduct = Helpers.Deserialize <GridModel <Product> >(responseData.Data); return(PartialView("_Content", listProduct)); }
public async Task <PartialViewResult> ViewHistory() { var listHistory = new GridModel <Payment>(); if (SystemSession.CurrentAccount != null) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Shop_ViewHistory + "/0" + "/" + SystemSession.CurrentAccount.AccountId.ToString() }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200) { listHistory = Helpers.Deserialize <GridModel <Payment> >(responseData.Data); } } return(PartialView("_History", listHistory)); }
public async Task <ResponseData> GetAccessToken(string email, string password) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_GetToken, HeaderValue = new HeaderValue() { AuthorizationType = "Basic", SecretUser = Configuarations.ClientId, SecretPass = Configuarations.ClientSecrets }, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("grant_type", "password"), new KeyValuePair <string, string>("username", email), new KeyValuePair <string, string>("password", Helpers.EncryptPassWord(password)) } }; return(await ConnectAPI.GetToken(requestInfor)); }
public async Task <ActionResult> Edit(int productId) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_GetInfor + "/" + productId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code != 200) { return(RedirectToAction("Index", "Product")); } Product product = Helpers.Deserialize <Product>(responseData.Data); return(PartialView("_Add", product)); }
public async Task <GridModel <ProductPrice> > GetListPriceFromProduct(int productId, int productCategoryId) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_GetListPricePG + "/0/" + productId.ToString() + "/" + productCategoryId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); GridModel <ProductPrice> listProductPrice = new GridModel <ProductPrice>(); if (responseData.Code == 200) { listProductPrice = Helpers.Deserialize <GridModel <ProductPrice> >(responseData.Data); } return(listProductPrice); }
public async Task <PartialViewResult> LoadContent(int pageIndex) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_MyOrder_GetListProduct + "/" + pageIndex.ToString() + "/" + OrganizationId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); var listProduct = new GridModel <Product>(); if (responseData.Code == 200) { listProduct = Helpers.Deserialize <GridModel <Product> >(responseData.Data); } return(PartialView("_Content", listProduct)); }
public async Task <ActionResult> Add(Product product) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_Product_Add, HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken }, FormValue = Helpers.ConvertObToKeyPair(product) }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code != 200) { ViewBag.ResultData = null; return(View("index")); } return(PartialView("_Add", product)); }
public async Task <Organization> GetInforOrganization() { RequestInfor requestInfor = new RequestInfor() { UrlBase = OrganizationId > 0 ? Configuarations.Url_GetInforOrganization + "/" + OrganizationId.ToString() : Configuarations.Url_GetInforOrganizationFromAcc + "/" + AccountId.ToString(), HeaderValue = new HeaderValue() { AuthorizationType = "Bearer", AuthorizationValue = AccessToken } }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200) { return(Helpers.Deserialize <Organization>(responseData.Data)); } return(new Organization() { OrganizationId = -1 }); }
public async Task <ActionResult> Register(Account acc)//async Task<ActionResult> { bool isValid = true; //Validate form data if (acc.Password != acc.RePassword) { isValid = false; ModelState.AddModelError("RePassword", "Nhập lại Password chưa đúng"); } //Validate logic data if (acc.AccountId == 0) { RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_CheckExistAccount + "/" + acc.Email }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); if (responseData.Code == 200 && bool.Parse(responseData.Data ?? "False")) { isValid = false; ModelState.AddModelError("Email", "Tài khoản của bạn đã được đăng ký trên hệ thống"); } if (responseData.Code != 200) { isValid = false; ModelState.AddModelError("", "Hệ thống đang bảo trì kỹ thuật, xin vui lòng quay lại sau!"); } } if (isValid) { acc.Password = acc.Password != "......" ? Helpers.EncryptPassWord(acc.Password) : ""; RequestInfor requestInfor = new RequestInfor() { UrlBase = Configuarations.Url_CreateAccount, FormValue = Helpers.ConvertObToKeyPair(acc) }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code != 200) { ModelState.AddModelError("", "Hệ thống đang bảo trì kỹ thuật, xin vui lòng quay lại sau!"); } else if (acc.AccountId == 0) { var tokenInfor = await GetAccessToken(acc.Email, acc.Password); if (tokenInfor.Code != 200) { return(await CreateSessionAccount(acc.Email, "")); } return(await CreateSessionAccount(acc.Email, tokenInfor.Data)); } else { return(RedirectToAction("Index", "Home")); } } return(View("_Register", acc)); }
public static async Task <ResponseData> ConnectRestAPI(RequestInfor requestInfor, MethodType type) { ResponseData responseData = new ResponseData(); try { using (HttpClient client = new HttpClient()) { if (requestInfor.HeaderValue != null) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(requestInfor.HeaderValue.AuthorizationType, requestInfor.HeaderValue.AuthorizationValue); } var request = new HttpResponseMessage(); switch (type) { case MethodType.GET: request = await client.GetAsync(requestInfor.UrlBase); break; case MethodType.POST: request = await client.PostAsync(requestInfor.UrlBase, new FormUrlEncodedContent(requestInfor.FormValue)); break; case MethodType.PUT: request = await client.PutAsync(requestInfor.UrlBase, new FormUrlEncodedContent(requestInfor.FormValue)); break; case MethodType.DELETE: request = await client.DeleteAsync(requestInfor.UrlBase); break; default: break; } if (request.StatusCode == HttpStatusCode.OK) { string resultData = request.Content.ReadAsStringAsync().Result; responseData = new ResponseData() { Code = (int)HttpStatusCode.OK, Data = resultData, Message = "Request successful!" }; } else if (request.StatusCode == HttpStatusCode.Unauthorized) { responseData = new ResponseData() { Code = (int)HttpStatusCode.Unauthorized, Message = "Bạn không có quyền thực hiện yêu cầu này!" }; } else { var errorData = Helpers.Deserialize <ErrorData>(request.Content.ReadAsStringAsync().Result); responseData = new ResponseData() { Code = (int)request.StatusCode, Message = errorData.error + " - " + errorData.error_description }; } } } catch (Exception e) { responseData = new ResponseData() { Code = 0, Message = "Hệ thống đang bảo trì hoặc gặp sự cố kỹ thuật, xin vui lòng quay lại sau! => " + e.Message }; // Write log file } return(responseData); }
public async Task <GridModel <Product> > MyOrder_GetListProduct(RequestParams pr) { RequestInfor requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlPaymentMyOrderGetListProduct + "/" + pr.PageIndex.ToString() + "/" + pr.OrganizationId.ToString() }; var responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.GET); var listProduct = new GridModel <Product>(); if (responseData.Code == 200) { listProduct = Helpers.Deserialize <GridModel <Product> >(responseData.Data); string listProductString = Helpers.Serialize(listProduct.Data); //Get infor product requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlCatalogShopGetListProduct, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("listProductString", listProductString) } }; responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code == 200) { var listProductInfor = Helpers.Deserialize <List <Product> >(responseData.Data); var newListProduct = new List <Product>(); foreach (var item in listProduct.Data) { item.Code = listProductInfor.FindLast(x => x.ProductId == item.ProductId).Code; item.Name = listProductInfor.FindLast(x => x.ProductId == item.ProductId).Name; newListProduct.Add(item); } listProduct.Data = newListProduct; } //Get infor account string listAccountString = Helpers.Serialize(listProduct.Data.Select(x => x.AccountId).Distinct().ToList()); requestInfor = new RequestInfor() { UrlBase = StaticConfig.UrlMyOrderGetListInforAccount, FormValue = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("listAccountString", listAccountString) } }; responseData = await ConnectAPI.ConnectRestAPI(requestInfor, MethodType.POST); if (responseData.Code == 200) { var listAccountInfor = Helpers.Deserialize <List <Account> >(responseData.Data); var newListProduct = new List <Product>(); foreach (var item in listProduct.Data) { var account = listAccountInfor.FindLast(x => x.AccountId == item.AccountId); item.AccountName = account.Firstname + " " + account.LastName; item.Phone = account.Phone; newListProduct.Add(item); } listProduct.Data = newListProduct; } } return(listProduct); }