public void LoadImageVariabe() { using (WebClient client = new WebClient()) { var link = ProductVariableController.GetAll(""); if (link.Count > 0) { foreach (var l in link) { if (!string.IsNullOrEmpty(l.Image)) { string li = l.Image; string fname = li.Replace("https://ann.com.vn/wp-content/uploads/", ""); try { client.DownloadFile(new Uri(li), Server.MapPath("~/uploads/" + fname + "")); } catch { } } } } } }
public void UpdateProductID() { DateTime currentDate = DateTime.Now; var product = ProductVariableController.GetAll(""); foreach (var p in product) { var pr = ProductController.GetBySKU(p.ParentSKU); if (pr != null) { ProductVariableController.UpdateProductID(p.ID, pr.ID); } string color = ""; string size = ""; if (!string.IsNullOrEmpty(p.color)) { color = p.color; } if (!string.IsNullOrEmpty(p.size)) { size = p.size; } if (!string.IsNullOrEmpty(color)) { var vcolor = VariableValueController.GetByVariableID(1); foreach (var c in vcolor) { if (color == c.VariableValueText) { ProductVariableValueController.Insert(p.ID, p.SKU, c.ID, c.VariableName, c.VariableValue, false, currentDate, "admin"); } } } if (!string.IsNullOrEmpty(size)) { var vsize = VariableValueController.GetByVariableID(2); foreach (var s in vsize) { if (size == s.VariableValueText) { ProductVariableValueController.Insert(p.ID, p.SKU, s.ID, s.VariableName, s.VariableValue, false, currentDate, "admin"); } } } } }