public async Task <IActionResult> ProductToAssortment(Assortments assrt) { string statusCode; Assortments receivedAssortments = new Assortments(); List <string> getResponse = await Helper.AddAssortmentProducts(assrt); statusCode = getResponse[0]; string getApiResponse = getResponse[1]; receivedAssortments = JsonConvert.DeserializeObject <Assortments>(getApiResponse); assrt.AssortmentDropDownList = await Utils.PopulateDropDownAssortment(); assrt.ProductList = await Utils.PopulateDropDownProduct(); if (statusCode == "201") // Check response { var selectedItem = assrt.AssortmentDropDownList.Find(p => p.Value == assrt.AssrtmntId.ToString()); var selectedItemProduct = assrt.ProductList.Find(p => p.Value == assrt.ProductId.ToString()); if (selectedItemProduct != null) { selectedItem.Selected = true; selectedItemProduct.Selected = true; ViewBag.Message = "Save !!" + "||Assortment ID: " + selectedItem.Value + "," + selectedItem.Text; ViewBag.Message += "|| Product ID:" + selectedItemProduct.Value + "," + selectedItemProduct.Text; } } else { ViewBag.Message = "Not Save"; } return(View(assrt)); }
// Get Assortment Data and Product Date for Add to AssortmentProduct public async Task <IActionResult> ProductToAssortment() { Assortments assrt = new Assortments(); assrt.AssortmentDropDownList = await Utils.PopulateDropDownAssortment(); // Api call for get Assortments Data assrt.ProductList = await Utils.PopulateDropDownProduct(); // Api call for get Products Data return(View(assrt)); }
public virtual void MergeToEquivalent(Producer producer, ISession session) { AddEquivalent(producer.Name); producer.Assortments .Where(a => Assortments.All(x => x.CatalogProduct.Id != a.CatalogProduct.Id)) .Select(a => new Assortment(a.CatalogProduct, this) { Checked = a.Checked }) .Each(a => Assortments.Add(a)); producer.Equivalents .Each(e => AddEquivalent(e.Name)); }
public async Task <IActionResult> GetAssortments(int id) { Assortments assortment = new Assortments(); List <string> getResponse = await Helper.GetAssortmentByID(id); // Call Api string statusCode = getResponse[0]; string apiResponse = getResponse[1]; assortment = JsonConvert.DeserializeObject <Assortments>(apiResponse); if (statusCode != "200") { ViewBag.Message = "Something Wrong.Try again"; } return(View(assortment)); }
public async Task <IActionResult> AddAssortments(Assortments assortment) { Assortments receivedAssortments = new Assortments(); List <string> getResponse = await Helper.AddAssortment(assortment); // Call Api string statusCode = getResponse[0]; string apiResponse = getResponse[1]; receivedAssortments = JsonConvert.DeserializeObject <Assortments>(apiResponse); if (statusCode == "201") { ViewBag.Message = "Save !!"; } else { ViewBag.Message = "Not Save"; } return(View(receivedAssortments)); }
public static async Task <List <string> > AddAssortment(Assortments assortment) // Api function for Add Assortment { string apiResponse = ""; string statusCode; List <string> responseList = new List <string>(); using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(assortment), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync(Config.BaseURL + Config.AssortmentBaseEndPoint + "/" + "AddAssortment", content)) { apiResponse = await response.Content.ReadAsStringAsync(); // Get Response Int32 responseHttpStatusCode = (Int32)response.StatusCode; // Get Status Code statusCode = responseHttpStatusCode.ToString(); responseList.Add(statusCode); responseList.Add(apiResponse); } } return(responseList); }