public ActionResult Create(tblAgency tblagency, FormCollection collection) { tblagency.DateCreate = DateTime.Now; string idUser = Request.Cookies["Username"].Values["UserID"]; tblagency.idUser = int.Parse(idUser); tblagency.Tag = StringClass.NameToTag(tblagency.Name); db.tblAgencies.Add(tblagency); db.SaveChanges(); #region [Updatehistory] var Groups = db.tblCapacities.Where(p => p.Active == true).OrderByDescending(p => p.id).Take(1).ToList(); string id = Groups[0].id.ToString(); clsSitemap.CreateSitemap("NhaPhanPhoi/" + StringClass.NameToTag(tblagency.Name) + "-" + tblagency.id + ".aspx", id, "Agency"); Updatehistoty.UpdateHistory("Add tblagency", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Agencyad/Index")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm danh mục mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Agencyad/Create")); } return(Redirect("Index")); }
public ActionResult AddCatenews(FormCollection fr) { try { var addType = fr["addType"]; string catename = fr["catename"]; string catep = fr["cateId"]; string order = fr["order"]; string catedes = fr["catedes"]; string note = fr["catenote"]; string titleseo = fr["titleseo"]; string keyseo = fr["keyseo"]; string desseo = fr["desseo"]; string ckHome = fr["ckHome"]; string ckActive = fr["ckActive"]; string cateAvata = fr["cateAvata"]; string key = StringClass.NameToTag(catename); Category cate = new Category(); cate.id = Guid.NewGuid().ToString(); cate.cateName = catename; cate.cateicon = fr["cateicon"]; cate.cateImage = fr["cateImage"]; cate.cateDescription = fr["cateDescription"]; cate.cateKey = checkTrung(key, ClassExten.typeNew); cate.cateType = ClassExten.typeNew; cate.cateActiveHome = ckHome == null ? false : true; cate.cateActive = ckActive == null ? false : true; cate.cateLang = lang; cate.cateLevel = ""; cate.titleSeo = titleseo; cate.desSeo = desseo; cate.keySeo = keyseo; cate.cateImage = cateAvata; cate.createDate = DateTime.Now; cate.updateDate = DateTime.Now; cate.cateOrder = Convert.ToInt32(order); cate.catepar_id = catep; cate.cate_cap = GetCap(catep); db.Categorys.Add(cate); db.SaveChanges(); Session["ok"] = "Thêm mới thành công!"; if (addType.Equals("0")) { return(Redirect("/Categorys/Catenew")); } else { return(Redirect("/Categorys/AddCatenews")); } } catch (Exception) { Session["erro"] = "Đã xảy ra lỗi vui lòng thử lại!"; return(Redirect("/Categorys/AddCatenews")); } }
private void button1_Click(object sender, EventArgs e) { int cnt; var driver = new ChromeDriver(); driver.Url = textBox1.Text; Thread.Sleep(4000); //var ele = driver.FindElementByClassName("shopee-page-controller"); //Actions ac = new Actions(driver); //ac.MoveToElement(ele); //ac.Perform(); //Thread.Sleep(5000); IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight)"); var items = driver.FindElementsByClassName("shop-search-result-view__item"); cnt = 0; int groupid = 4; string groupname = "Phụ kiện khác"; //int groupid = InsertDataGroup(groupname); foreach (var item in items) { Products pro = new Products(); var data = item.FindElement(By.ClassName("_36CEnF")); pro.Name = data.Text; //var price = item.FindElement(By.ClassName("_3_-SiN")); //if (price != null) //{ // pro.Price = "₫" + price.Text; //} var price1 = item.FindElements(By.ClassName("_29R_un")); if (price1.Count == 1) { pro.Price = "₫" + price1[0].Text; } if (price1.Count == 2) { pro.Price = "₫" + price1[0].Text + " - ₫" + price1[1].Text; } var img = item.FindElements(By.TagName("img")); pro.Image = img[0].GetAttribute("src"); if (!File.Exists("Images\\" + StringClass.NameToTag(pro.Name) + ".jpg") && pro.Image != null) { SaveImage("Images\\" + StringClass.NameToTag(pro.Name) + ".jpg", ImageFormat.Jpeg, pro.Image); } pro.Image = "\\Images\\" + StringClass.NameToTag(pro.Name) + ".jpg"; cnt++; InsertData(cnt, pro, groupid, groupname); } Activate(); MessageBox.Show("Get " + cnt.ToString() + " products"); }
public ActionResult Edit(tblProductSyn tblProductsyn, int id, FormCollection collection) { if (ModelState.IsValid) { tblProductsyn.Tag = StringClass.NameToTag(tblProductsyn.Name); string[] listarray = tblProductsyn.ImageLinkDetail.Split('/'); string ImageLinkDetail = collection["ImageLinkDetail"]; string imagethum = listarray[listarray.Length - 1]; tblProductsyn.ImageLinkThumb = "/Images/_thumbs/Images/" + imagethum; db.Entry(tblProductsyn).State = EntityState.Modified; db.SaveChanges(); var listsyn = db.ProductConnects.Where(p => p.idSyn == id).ToList(); if (listsyn.Count > 0) { for (int i = 0; i < listsyn.Count; i++) { Int32 idpp = listsyn[i].id; var listchld = db.ProductConnects.First(p => p.id == idpp); db.ProductConnects.Remove(listchld); db.SaveChanges(); } } string Chuoisyn = collection["CodeSyn"]; string[] Mang = Chuoisyn.Split(','); ProductConnect productconnect = new ProductConnect(); var listproductSyn = db.tblProductSyns.OrderByDescending(p => p.id).Take(1).ToList(); int idsyn = int.Parse(listproductSyn[0].id.ToString()); for (int i = 0; i < Mang.Length; i++) { productconnect.idSyn = id; string idpd = Mang[i].ToString(); productconnect.idpd = idpd; db.ProductConnects.Add(productconnect); db.SaveChanges(); } clsSitemap.UpdateSitemap("syn/" + StringClass.NameToTag(tblProductsyn.Name), id.ToString(), "ProductSYN"); #region [Updatehistory] Updatehistoty.UpdateHistory("Edit tblProductsyn", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/ProductSYNad/Index")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/ProductSYNad/Create")); } } return(View(tblProductsyn)); }
public ActionResult UpdateCatepro(FormCollection fr, string id) { try { //int catetype = Convert.ToInt32(fr["catetype"]); string catename = fr["catename"]; string catep = fr["cateId"]; string order = fr["order"]; string catedes = fr["catedes"]; string note = fr["catenote"]; string titleseo = fr["titleseo"]; string keyseo = fr["keyseo"]; string desseo = fr["desseo"]; string ckHome = fr["ckHome"]; string ckActive = fr["ckActive"]; // string cateAvata = fr["cateAvata"]; string key = StringClass.NameToTag(catename); Category cate = db.Categorys.FirstOrDefault(u => u.id == id); cate.cateName = catename; cate.cateicon = fr["cateicon"]; cate.cssClass = fr["cssClass"]; cate.cateImage = fr["cateImage"]; cate.cateDescription = fr["cateDescription"]; if (cate.cateKey != key) { cate.cateKey = checkTrungUpdate(key, ClassExten.typePro, id); } cate.cateType = ClassExten.typePro; cate.cateActiveHome = true; cate.cateActive = true; cate.cateActiveHome = ckHome == null ? false : true; cate.cateActive = ckActive == null ? false : true; cate.cateLang = lang; cate.cateLevel = ""; cate.titleSeo = titleseo; cate.desSeo = desseo; cate.keySeo = keyseo; // cate.cateImage = cateAvata; cate.updateDate = DateTime.Now; cate.cateOrder = Convert.ToInt32(order); cate.catepar_id = catep; cate.cate_cap = GetCap(catep); db.SaveChanges(); Session["ok"] = "Cập nhật thành công!"; } catch (Exception) { Session["erro"] = "Đã xảy ra lỗi vui lòng thử lại!"; return(Redirect("/Categorys/UpdateCatepro" + id)); } return(Redirect("/Categorys/Catepro")); }
public ActionResult Create(tblNew tblnews, FormCollection Collection, string id, int[] MutilMenu) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } string nidCate = Collection["drMenu"]; if (nidCate != "") { tblnews.idCate = int.Parse(nidCate); int idcate = int.Parse(nidCate); tblnews.DateCreate = DateTime.Now; tblnews.Tag = StringClass.NameToTag(tblnews.Name); tblnews.DateCreate = DateTime.Now; string idUser = Request.Cookies["Username"].Values["UserID"]; tblnews.idUser = int.Parse(idUser); StringClass.NewsCreateTag(tblnews.id, tblnews.Keyword); db.tblNews.Add(tblnews); db.SaveChanges(); var listprro = db.tblNews.OrderByDescending(p => p.id).Take(1).ToList(); clsSitemap.CreateSitemap("tin-tuc/" + tblnews.Tag, listprro[0].id.ToString(), "News"); #region [Updatehistory] Updatehistoty.UpdateHistory("Create News", Request.Cookies["Username"].Values["Username"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion var ListNews = db.tblNews.OrderByDescending(p => p.id).Take(1).ToList(); int idNews = int.Parse(ListNews[0].id.ToString()); if (MutilMenu != null) { foreach (var idCate in MutilMenu) { tblConnectNew tblconnectnews = new tblConnectNew(); tblconnectnews.idCate = idCate; tblconnectnews.idNew = idNews; db.tblConnectNews.Add(tblconnectnews); db.SaveChanges(); } } if (Collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm tinthành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Newsad/index?idCate=" + nidCate + "")); } if (Collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm tin thành công, mời bạn thêm tin mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Newsad/Create?id=" + nidCate + "")); } } return(View()); }
public ActionResult Create(TblGroupProduct TblGroupProduct, int[] MutilMenuGroup, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } string drMenu = collection["drMenu"]; if (drMenu == "") { TblGroupProduct.ParentId = null; } else { var dbLeve = db.TblGroupProduct.Find(int.Parse(drMenu)); TblGroupProduct.ParentId = dbLeve.Id; } TblGroupProduct.DateCreate = DateTime.Now; string IdUser = Request.Cookies["Username"].Values["UserID"]; TblGroupProduct.IdUser = int.Parse(IdUser); TblGroupProduct.Tag = StringClass.NameToTag(TblGroupProduct.Name); db.TblGroupProduct.Add(TblGroupProduct); db.SaveChanges(); var Groups = db.TblGroupProduct.Where(p => p.Active == true).OrderByDescending(p => p.Id).Take(1).ToList(); string id = Groups[0].Id.ToString(); clsSitemap.CreateSitemap(StringClass.NameToTag(TblGroupProduct.Name), id, "GroupProduct"); if (MutilMenuGroup != null) { foreach (var item in MutilMenuGroup) { TblConnectGroupProduct conntect = new TblConnectGroupProduct(); conntect.Idg = int.Parse(id); conntect.Idc = item; db.TblConnectGroupProduct.Add(conntect); db.SaveChanges(); } } if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm danh mục thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/GroupProduct/Index?idCate=" + drMenu)); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm danh mục thành công, mời bạn thêm danh mục sản phẩm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/GroupProduct/Create?id=" + drMenu + "")); } return(Redirect("/GroupProduct/Index?idCate=" + drMenu)); }
public ActionResult MenuEdit_back(int id, FormCollection collection) { if (Request.Cookies["Username"] != null) { var page = db.Menus.First(m => m.Id == id); page.Name = collection["Name"]; if (collection["PageTypeDDL"] == "0") { //Lien ket if (collection["LinkDDL"] == "0") { page.Link = collection["Link"]; } else if (collection["LinkDDL"] == "1") { page.Link = collection["LinkModule"]; } else if (collection["LinkDDL"] == "2") { page.Link = "/san-pham"; } else { page.Link = "/tin-tuc"; } page.IdCategory = null; } else { //Noi dung page.Link = "/gioi-thieu/" + StringClass.NameToTag(collection["Name"].ToString()) + ""; page.IdCategory = 0; } page.Target = collection["Target"]; page.Position = Convert.ToInt32(collection["Position"]); page.Content = collection["Content"]; page.Detail = collection["Detail"]; page.Title = collection["Title"]; page.Description = collection["Description"]; page.Keyword = collection["Keyword"]; page.Ord = Convert.ToInt32(collection["Ord"]); page.Active = (collection["Active"] == "false") ? false : true; //var str = Level; //page.Level = Level; page.Tag = onsoft.Models.StringClass.NameToTag(collection["Name"]); db.SaveChanges(); return(RedirectToAction("MenuIndex")); } else { return(RedirectToAction("admins")); } }
public ActionResult GroupNewEditot(int id, FormCollection collection) { if (Request.Cookies["Username"] != null) { var catego = db.GroupNews.Find(id); // Lấy dữ liệu từ view int parentId = 0; string level = "00000"; if (collection["GroupNew"] != "") { parentId = Int32.Parse(collection["GroupNew"]); string parentLevel = db.GroupNews.Where(g => g.Id == parentId).SingleOrDefault().Level; level = parentLevel + "00000"; } catego.Level = level; string name = collection["Name"]; if (catego.Level.Length > 5) { catego.Name = name.Substring(catego.Level.Length - 5, name.Length - (catego.Level.Length - 5)); } else { catego.Name = name; } catego.Title = collection["Title"]; catego.Description = collection["Description"]; catego.Keyword = collection["Keyword"]; catego.Ord = Convert.ToInt32(collection["Ord"]); catego.Tag = StringClass.NameToTag(collection["Name"]); catego.Priority = (collection["Priority"] == "false") ? false : true; catego.Index = (collection["Index"] == "false") ? false : true; catego.Active = (collection["Active"] == "false") ? false : true; catego.Lang = Session["Lang"] != null ? Session["Lang"].ToString() : "vi"; string groid = collection["Cat"]; if (groid != null && groid != "") { catego.GrpID = int.Parse(groid); } else { catego.GrpID = 0; } db.Entry(catego).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("GroupNewIndexot")); } else { return(Redirect("/Admins/admins")); } }
public ActionResult Update(Tagpro model) { if (!string.IsNullOrEmpty(model.tagId)) { //check trung update var check = db.Tagproes.FirstOrDefault(u => !u.tagId.Equals(model.tagId) && u.tagType == 1 && u.tagName.ToLower().Equals(model.tagName.ToLower())); if (check != null) { return(Json(new { ok = false, mess = "Tên thẻ tag đã tồn tại" }, JsonRequestBehavior.AllowGet)); } } else { //check trung them moi var check = db.Tagproes.FirstOrDefault(u => u.tagType == 1 && u.tagName.ToLower().Equals(model.tagName.ToLower())); if (check != null) { return(Json(new { ok = false, mess = "Tên thẻ tag đã tồn tại" }, JsonRequestBehavior.AllowGet)); } } try { if (string.IsNullOrEmpty(model.tagId)) { Tagpro data = new Tagpro(); data.tagId = Guid.NewGuid().ToString(); data.tagName = model.tagName; data.tagKey = StringClass.NameToTag(model.tagName.Trim().ToLower()); data.tagOrder = model.tagOrder; data.tagType = 1;//sp db.Tagproes.Add(data); db.SaveChanges(); return(Json(new { ok = true, mess = "" }, JsonRequestBehavior.AllowGet)); } else { var data = db.Tagproes.FirstOrDefault(u => u.tagId.Equals(model.tagId)); data.tagName = model.tagName; data.tagKey = StringClass.NameToTag(model.tagName.Trim().ToLower()); data.tagOrder = model.tagOrder; data.tagType = 1; db.SaveChanges(); return(Json(new { ok = true, mess = "" }, JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(new { ok = false, mess = "Có lỗi phát sinh, vui lòng thử lại" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GenNewKey(string name) { try { string rs = ""; rs = StringClass.NameToTag(name.ToLower()).Replace(" ", "").Replace(System.Environment.NewLine, string.Empty); return(Json(new { ok = true, rs = rs }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { ok = false, rs = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult tagurl() { var listGroup = db.tblGroupProducts.ToList(); for (int i = 0; i < listGroup.Count; i++) { int id = listGroup[i].id; tblGroupProduct groupproduct = db.tblGroupProducts.Find(id); groupproduct.Tag = StringClass.NameToTag(groupproduct.Name); db.SaveChanges(); } return(View()); }
public ActionResult agencyDetail(string tag) { var tblagency = db.tblAgencies.First(p => p.Tag == tag); ViewBag.Title = "<title>" + tblagency.Name + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + tblagency.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + tblagency.Tabs + "\" /> "; ViewBag.dcTitle = "<meta name=\"DC.title\" content=\"" + tblagency.Name + "\" />"; ViewBag.dcDescription = "<meta name=\"DC.description\" content=\"" + tblagency.Description + "\" />"; string meta = ""; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Loiloc.com/dai-ly" + StringClass.NameToTag(tag) + "\" />"; meta += "<meta itemprop=\"name\" content=\"" + tblagency.Name + "\" />"; meta += "<meta itemprop=\"url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta itemprop=\"description\" content=\"" + tblagency.Description + "\" />"; meta += "<meta itemprop=\"image\" content=\"http://Loiloc.com" + tblagency.Images + "\" />"; meta += "<meta property=\"og:title\" content=\"" + tblagency.Name + "\" />"; meta += "<meta property=\"og:type\" content=\"product\" />"; meta += "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta property=\"og:image\" content=\"http://Loiloc.com" + tblagency.Images + "\" />"; meta += "<meta property=\"og:site_name\" content=\"http://Loiloc.com\" />"; meta += "<meta property=\"og:description\" content=\"" + tblagency.Description + "\" />"; meta += "<meta property=\"fb:admins\" content=\"\" />"; ViewBag.Descriptionss = tblagency.Description; ViewBag.Meta = meta; //load tag string chuoitag = ""; if (tblagency.Tabs != null) { string Chuoi = tblagency.Tabs; string[] Mang = Chuoi.Split(','); List <int> araylist = new List <int>(); for (int i = 0; i < Mang.Length; i++) { chuoitag += "<h2><a href=\"/tagsAgency/" + StringClass.NameToTag(Mang[i]) + "\" title=\"" + Mang[i] + "\">" + Mang[i] + "</a></h2>"; } } ViewBag.chuoitag = chuoitag; //Load root ViewBag.nUrl = "<a href=\"/\" title=\"Trang chủ\" rel=\"nofollow\"><span class=\"iCon\"></span> Trang chủ</a><i></i> / " + tblagency.Name + ""; return(View(tblagency)); }
public ActionResult Create(tblGroupNew tblgroupnews, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } string drMenu = collection["drMenu"]; string nLevel; if (drMenu == "") { tblgroupnews.ParentID = null; } else { var dbLeve = db.tblGroupNews.Find(int.Parse(drMenu)); tblgroupnews.ParentID = dbLeve.id; } tblgroupnews.DateCreate = DateTime.Now; string idUser = Request.Cookies["Username"].Values["UserID"]; tblgroupnews.idUser = int.Parse(idUser); tblgroupnews.Tag = StringClass.NameToTag(tblgroupnews.Name); db.tblGroupNews.Add(tblgroupnews); db.SaveChanges(); Updatehistoty.UpdateHistory("Add Group Product", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); var Groups = db.tblGroupNews.Where(p => p.Active == true).OrderByDescending(p => p.id).Take(1).ToList(); string id = Groups[0].id.ToString(); clsSitemap.CreateSitemap(StringClass.NameToTag(tblgroupnews.Name), id, "GroupNews"); if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm danh mục thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/GroupNews/Index?idCate=" + drMenu)); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm danh mục thành công, mời bạn thêm danh mục mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/GroupNews/Create?id=" + drMenu + "")); } return(Redirect("/GroupNews/Index?idCate=" + drMenu)); }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { string Link = ""; string Id = txtId.Value; Data.Page obj = new Data.Page(); obj.Id = Id; obj.Name = txtName.Text; obj.Image = DateTime.Now.ToString(); obj.Detail = fckDetail.Value; obj.Level = Level + "00000"; obj.Description = txtContent.Text; obj.Keyword = ""; obj.Type = ddlType.SelectedValue; obj.Link = txtLink.Text; obj.Target = ddlTarget.SelectedValue; obj.Position = ddlPosition.SelectedValue; obj.Language = ddlLanguage.SelectedValue; obj.Ord = txtOrd.Text != "" ? txtOrd.Text : "1"; obj.Active = chkActive.Checked ? "1" : "0"; if (Insert == true) { PageService.Page_Insert(obj); Id = sql.MaxId("Page", "Id"); } else { PageService.Page_Update(obj); } if (ddlType.SelectedValue == "2") { DataTable dt = new DataTable(); dt = PageService.Page_GetById(Id); Link = "/trang-tin/" + StringClass.NameToTag(dt.Rows[0]["Name"].ToString()) + "-" + Id; sql.ExecuteNonQuery("Update Page set Link='" + Link + "' Where Id='" + Id + "'"); } BindGrid(); pnView.Visible = true; pnUpdate.Visible = false; Level = ""; Insert = false; } }
public ActionResult Edit(tblManufacture tblmanufacture, int id, FormCollection collection, int[] MutilMenu) { if (ModelState.IsValid) { tblmanufacture.Tag = StringClass.NameToTag(tblmanufacture.Name); db.Entry(tblmanufacture).State = EntityState.Modified; db.SaveChanges(); var ListManu = db.tblConnectManuProducts.Where(p => p.idManu == id).ToList(); for (int i = 0; i < ListManu.Count; i++) { db.tblConnectManuProducts.Remove(ListManu[i]); db.SaveChanges(); } if (MutilMenu != null) { foreach (var idCates in MutilMenu) { tblConnectManuProduct tblmanufactures = new tblConnectManuProduct(); tblmanufactures.idCate = idCates; tblmanufactures.idManu = id; db.tblConnectManuProducts.Add(tblmanufactures); db.SaveChanges(); } } clsSitemap.UpdateSitemap("hang-san-xuat/" + tblmanufacture.Tag, id.ToString(), "Manufactures"); #region [Updatehistory] Updatehistoty.UpdateHistory("Edit tblmanufactures", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Manufacturesad/Index")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Manufacturesad/Create")); } } return(View(tblmanufacture)); }
public ActionResult GroupProductCreateot(FormCollection collection, GroupProduct catego) { if (Request.Cookies["Username"] != null) { // Lấy dữ liệu từ view int parentId = 0; string level = "00000"; if (collection["GroupProduct"] != "0") { if (collection["GroupProduct"] != "") { parentId = Int32.Parse(collection["GroupProduct"]); string parentLevel = db.GroupProducts.Where(g => g.Id == parentId).SingleOrDefault().Level; level = parentLevel + "00000"; } } catego.Level = level; catego.ParentId = parentId; catego.Name = collection["Name"]; catego.Title = collection["Title"]; catego.Description = collection["Description"]; catego.Keyword = collection["Keyword"]; catego.Ord = Convert.ToInt32(collection["Ord"]); catego.Tag = StringClass.NameToTag(collection["Name"]); catego.Priority = (collection["Priority"] == "false") ? false : true; catego.Index = (collection["Index"] == "false") ? false : true; catego.Active = (collection["Active"] == "false") ? false : true; catego.Icon = collection["Icon"]; catego.Images = collection["Images"]; catego.BaoHanh = collection["Baohanh"]; catego.Detail = collection["Detail"]; db.Entry(catego).State = EntityState.Added; db.SaveChanges(); return(RedirectToAction("GroupProductIndexot")); } else { return(Redirect("/Admins/admins")); } }
// GET: Convert public ActionResult Index() { var listProduct = db.tblNews.ToList(); foreach (var item in listProduct) { int id = item.id; tblNew tblproduct = db.tblNews.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } var listProducts = db.tblGroupNews.ToList(); foreach (var item in listProducts) { int id = item.id; tblGroupNew tblproduct = db.tblGroupNews.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } var listProductss = db.tblAgencies.ToList(); foreach (var item in listProductss) { int id = item.id; tblAgency tblproduct = db.tblAgencies.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } var listProducstsss = db.tblGroupAgencies.ToList(); foreach (var item in listProducstsss) { int id = item.id; tblGroupAgency tblproduct = db.tblGroupAgencies.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } return(View()); }
public ActionResult Edit(tblAgency tblagency, int id, FormCollection collection) { if (ModelState.IsValid) { string idUser = Request.Cookies["Username"].Values["UserID"]; tblagency.idUser = int.Parse(idUser); bool URL = (collection["URL"] == "false") ? false : true; if (URL == true) { tblagency.Tag = StringClass.NameToTag(tblagency.Name); } else { tblagency.Tag = collection["NameURL"]; } tblagency.DateCreate = DateTime.Now; db.Entry(tblagency).State = EntityState.Modified; db.SaveChanges(); clsSitemap.UpdateSitemap("4/" + StringClass.NameToTag(tblagency.Name) + "-" + tblagency.id + ".aspx", id.ToString(), "Capacity"); #region [Updatehistory] Updatehistoty.UpdateHistory("Edit Agency", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Agencyad/Index")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Agencyad/Create")); } } return(View(tblagency)); }
public ActionResult Create(tblService tblservice, FormCollection collection) { tblservice.DateCreate = DateTime.Now; tblservice.Tag = StringClass.NameToTag(tblservice.Name); db.tblServices.Add(tblservice); db.SaveChanges(); #region [Updatehistory] Updatehistoty.UpdateHistory("Add tblservice", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/servicead/Index")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm danh mục mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/servicead/Create")); } return(Redirect("Index")); }
public ActionResult Edit(tblGuarantee tblGuarantee, int id, FormCollection collection) { if (ModelState.IsValid) { bool URL = (collection["URL"] == "false") ? false : true; int ids = int.Parse(collection["drDistrict"].ToString()); int idCates = int.Parse(collection["drManu"].ToString()); tblGuarantee.idDistrict = ids; tblGuarantee.DateCreate = DateTime.Now; tblGuarantee.idManu = idCates; if (URL == true) { tblGuarantee.Tag = StringClass.NameToTag(tblGuarantee.Name); } else { tblGuarantee.Tag = collection["NameURL"]; } tblGuarantee.Tag = StringClass.NameToTag(tblGuarantee.Name); db.Entry(tblGuarantee).State = EntityState.Modified; db.SaveChanges(); #region [Updatehistory] Updatehistoty.UpdateHistory("Edit tblGuarantee", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Guaranteead/Index?id=" + ids + "&idCate=" + idCates + "")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Guaranteead/Create?id=" + ids + "&idCate=" + idCates + "")); } } return(View(tblGuarantee)); }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { Data.News obj = new Data.News(); obj.Id = Id; obj.Name = txtName.Text; obj.Image = txtImage.Text; obj.File = ""; obj.Content = txtContent.Text; obj.Detail = fckDetail.Value; obj.Date = DateTimeClass.ConvertDateTime(txtDate.Text, "MM/dd/yyyy HH:mm:ss"); obj.Index = "0"; obj.Ord = txtOrd.Text != "" ? txtOrd.Text : "1"; obj.Active = chkActive.Checked ? "1" : "0"; obj.Position = ddlPosition.SelectedValue; obj.GroupNewsId = ddlGroupNews.SelectedValue; obj.GroupTagNews = StringClass.NameToTag(ddlGroupNews.SelectedItem.Text); obj.Description = ""; obj.Keyword = ""; obj.Views = "0"; obj.LinkDemo = ""; obj.Language = ddlLanguage.SelectedValue; if (Insert == true) { NewsService.News_Insert(obj); } else { NewsService.News_Update(obj); } BindGrid(where); pnView.Visible = true; pnUpdate.Visible = false; Insert = false; } }
public ActionResult Update(Brand model) { var check = db.Brands.FirstOrDefault(u => !u.id.Equals(model.id) && u.bkName.ToLower().Equals(model.bkName.ToLower())); if (check != null) { return(Json(new { ok = false, mess = "Tên thương hiệu đã tồn tại" }, JsonRequestBehavior.AllowGet)); } try { Brand data = db.Brands.FirstOrDefault(u => u.id.Equals(model.id)); data.bkName = model.bkName; data.bkImage = model.bkImage; data.note = model.note; data.numberOder = model.numberOder; data.bkKey = StringClass.NameToTag(model.bkName); db.SaveChanges(); return(Json(new { ok = true, mess = "" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { ok = false, mess = "" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(tblManufacture tblmanu, FormCollection collection, int[] MutilMenu) { tblmanu.Tag = StringClass.NameToTag(tblmanu.Name); db.tblManufactures.Add(tblmanu); db.SaveChanges(); var ListManu = db.tblManufactures.OrderByDescending(p => p.id).Take(1).ToList(); int idManu = int.Parse(ListManu[0].id.ToString()); if (MutilMenu != null) { foreach (var idCate in MutilMenu) { tblConnectManuProduct tblManufactures = new tblConnectManuProduct(); tblManufactures.idCate = idCate; tblManufactures.idManu = idManu; db.tblConnectManuProducts.Add(tblManufactures); db.SaveChanges(); } } var ListManufac = db.tblManufactures.OrderByDescending(p => p.id).Take(1).ToList(); clsSitemap.CreateSitemap("hang-san-xuat/" + ListManufac[0].Tag, ListManufac[0].id.ToString(), "Manufactures"); Updatehistoty.UpdateHistory("Add tblManufactures", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Manufacturesad/Index")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Manufacturesad/Create")); } return(Redirect("Index")); }
public ActionResult Update(FormCollection f, string id) { try { var data = db.Products.First(u => u.id.Equals(id)); if (data.pro_view == null) { data.pro_view = 0; } data.groupId = f["cateId"]; data.proPrice = int.Parse(f["price"]); data.proPrice_sale = int.Parse(f["priceSale"]); data.pro_name = f["proName"]; data.proCode = f["proCode"]; string keyTag = StringClass.NameToTag(data.pro_name.ToLower()).Replace(" ", ""); var key = checkTrungUpdate(keyTag, data.id); data.pro_key = key; data.proFile = f["proFile"]; data.brandId = f["brandId"]; data.proContentTab1 = f["proContentTab1"]; data.proContentTab2 = f["proContentTab2"]; data.proContentTab3 = f["proContentTab3"]; data.proOrder = int.Parse(f["proOrder"]); //check var pro_new = f["pro_new"]; var pro_hot = f["proHot"]; var active = f["proStatus"]; data.pro_new = pro_new == null ? false : true; data.pro_hot = pro_hot == null ? false : true; data.active = active == null ? false : true; //seo data.desSeo = f["desSeo"]; data.titleSeo = f["titleSeo"]; data.keySeo = f["keySeo"]; //ảnh data.proAvata = f["proAvata"]; data.proImages1 = f["proAvata1"]; data.proImages2 = f["proAvata2"]; data.proImages3 = f["proAvata3"]; data.proImages4 = f["proAvata4"]; data.proImages5 = f["proAvata5"]; //hết ảnh data.updateDate = DateTime.Now; #region [giai phap] var protag = db.ProTags.Where(u => u.proId.Equals(data.id)); if (protag.Count() > 0) { db.ProTags.RemoveRange(protag); } string tagId = ""; var Faqnumber = 0;// Convert.ToInt32(f["Tagnumber"]); if (Faqnumber > 0) { ProTag pros; for (int i = 0; i < Faqnumber; i++) { tagId = f["ckTag_" + i]; if (tagId != null) { pros = new ProTag(); pros.idPT = Guid.NewGuid().ToString(); pros.proId = data.id; pros.tagId = f["valueTag_" + i]; db.ProTags.Add(pros); } } } #endregion db.SaveChanges(); Session["ok"] = "Cập nhật sản phẩm thành công!"; return(Redirect("/Prodcuts/Index")); } catch (Exception) { Session["erro"] = "Đã xảy ra lỗi vui lòng thử lại!"; return(Redirect("/Prodcuts/Update/" + id)); } }
public ActionResult Add(FormCollection f) { try { var addType = f["addType"]; Product data = new Product(); data.id = Guid.NewGuid().ToString(); data.pLang = lang; data.pro_view = 0; data.proPrice = int.Parse(f["price"]); data.proPrice_sale = int.Parse(f["priceSale"]); data.groupId = f["cateId"]; data.pro_name = f["proName"]; data.proCode = f["proCode"]; string keyTag = StringClass.NameToTag(data.pro_name.ToLower()).Replace(" ", ""); var key = checkTrung(keyTag); data.pro_key = key; data.proFile = f["proFile"]; data.brandId = f["brandId"]; data.proContentTab1 = f["proContentTab1"]; data.proContentTab2 = f["proContentTab2"]; data.proContentTab3 = f["proContentTab3"]; data.proOrder = int.Parse(f["proOrder"]); //check var pro_new = f["pro_new"]; var pro_hot = f["proHot"]; var active = f["proStatus"]; data.pro_new = pro_new == null ? false : true; data.pro_hot = pro_hot == null ? false : true; data.active = active == null ? false : true; //seo data.desSeo = f["desSeo"]; data.titleSeo = f["titleSeo"]; data.keySeo = f["keySeo"]; //ảnh data.proAvata = f["proAvata"]; data.proImages1 = f["proAvata1"]; data.proImages2 = f["proAvata2"]; data.proImages3 = f["proAvata3"]; data.proImages4 = f["proAvata4"]; data.proImages5 = f["proAvata5"]; data.createDate = DateTime.Now; data.updateDate = DateTime.Now; db.Products.Add(data); #region [giai phap] string tagId = ""; var Faqnumber = 0;// Convert.ToInt32(f["Tagnumber"]); if (Faqnumber > 0) { ProTag pros; for (int i = 0; i < Faqnumber; i++) { tagId = f["ckTag_" + i]; if (tagId != null) { pros = new ProTag(); pros.idPT = Guid.NewGuid().ToString(); pros.proId = data.id; pros.tagId = f["valueTag_" + i]; db.ProTags.Add(pros); } } } #endregion db.SaveChanges(); Session["ok"] = "Thêm mới sản phẩm thành công!"; if (addType.Equals("0")) { return(Redirect("/Prodcuts/Index")); } else { return(Redirect("/Prodcuts/Add")); } } catch (Exception) { Session["erro"] = "Đã xảy ra lỗi vui lòng thử lại!"; return(Redirect("/Prodcuts/Add/")); } }
private void LoadDropDownListPageLink() { ddlLink.Items.Clear(); ddlLink.Items.Add(new ListItem("Trang chủ", "/")); DataTable dt = new DataTable(); dt = GroupNewsService.GroupNews_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Tin tức", "#")); for (int i = 0; i < dt.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(dt.Rows[i]["Name"].ToString(), dt.Rows[i]["Level"].ToString() + "00000"), PageHelper.GeneralGroupUrl(Consts.CON_TIN_TUC, dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Name"].ToString()))); } List <Data.GroupImages> listG = GroupImagesService.GroupImages_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Hình ảnh", "#")); if (listG.Count > 0) { for (int i = 0; i < listG.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listG[i].Name, listG[i].Level + "00000"), "/Thu-vien-anh/" + listG[i].Id + "/" + StringClass.NameToTag(listG[i].Name))); } } DataTable listGProduct = GroupProductService.GroupProduct_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Sản phẩm", "#")); if (listGProduct.Rows.Count > 0) { for (int i = 0; i < listGProduct.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listGProduct.Rows[i]["Name"].ToString(), listGProduct.Rows[i]["Level"].ToString() + "00000"), PageHelper.GeneralGroupUrl(Consts.CON_SAN_PHAM, listGProduct.Rows[i]["Id"].ToString(), listGProduct.Rows[i]["Name"].ToString()))); } } DataTable listChude = ChudeService.Chude_GetByTop("", "Active=1", "Ord"); ddlLink.Items.Add(new ListItem("Chủ đề", "#")); if (listChude.Rows.Count > 0) { for (int i = 0; i < listChude.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listChude.Rows[i]["Name"].ToString(), "0000000000"), "/chu-de/chu-de-" + listChude.Rows[i]["Id"].ToString() + "/" + StringClass.NameToTag(listChude.Rows[i]["Name"].ToString()))); } } ddlLink.Items.Add(new ListItem("Liên hệ", "/lien-he")); ddlLink.DataBind(); }
public ActionResult Edit(tblGroupNew tblgroupnews, FormCollection collection, int id) { string drMenu = collection["drMenu"]; string nLevel = ""; if (drMenu == "") { tblgroupnews.ParentID = null; var counts = db.tblGroupNews.Where(p => p.ParentID == null).OrderByDescending(p => p.Ord).Take(1).ToList(); } else { if (drMenu != id.ToString()) { var dbLeve = db.tblGroupNews.Find(int.Parse(drMenu)); tblgroupnews.ParentID = dbLeve.id; } } string idUser = Request.Cookies["Username"].Values["UserID"]; tblgroupnews.idUser = int.Parse(idUser); bool URL = (collection["URL"] == "false") ? false : true; if (URL == true) { tblgroupnews.Tag = StringClass.NameToTag(tblgroupnews.Name); } else { tblgroupnews.Tag = collection["NameURL"]; } clsSitemap.CreateSitemap(tblgroupnews.Tag, id.ToString(), "GroupNews"); tblgroupnews.DateCreate = DateTime.Now; db.Entry(tblgroupnews).State = EntityState.Modified; db.SaveChanges(); #region [Updatehistory] Updatehistoty.UpdateHistory("Edit tblgroupnews", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { if (drMenu == "") { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa danh mục thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/GroupNews/Index?id=" + drMenu + "")); } else { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa danh mục thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; var checkgroup = db.tblGroupNews.Where(p => p.id == int.Parse(drMenu)).ToList(); if (checkgroup.Count > 0) { return(Redirect("/GroupNews/Index?idCate=" + checkgroup[0].id)); } } } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã sửa danh mục thành công, mời bạn thêm danh mục mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/GroupNews/Create?id=" + drMenu + "")); } return(Redirect("/GroupNews/")); }
public ActionResult newsDetail(string tag) { tblNew tblnews = db.tblNews.First(p => p.Tag == tag); int id = tblnews.id; int idmenu = int.Parse(tblnews.idCate.ToString()); tblGroupNew groupNews = db.tblGroupNews.First(p => p.id == idmenu); ViewBag.menuName = groupNews.Name; ViewBag.tagMenuName = groupNews.Tag; var listId = db.tblConnectManuToNews.Where(p => p.idNews == id).Select(p => p.idManu).Take(1).ToList(); Session["idManu"] = ""; int idManu = int.Parse(listId[0].Value.ToString()); var manufactures = db.SelectListItem.Find(idManu); ViewBag.manuName = manufactures.Name; ViewBag.color = manufactures.Color; Session["idManu"] = idManu; if (tblnews.Style == true) { ViewBag.style = "width:100% !important; margin:0px"; ViewBag.style1 = "display:none"; } ViewBag.Title = "<title>" + tblnews.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + tblnews.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + tblnews.Keyword + "\" /> "; ViewBag.dcTitle = "<meta name=\"DC.title\" content=\"" + tblnews.Title + "\" />"; if (tblnews.Meta != null && tblnews.Meta != "") { int phut = DateTime.Now.Minute * 2; ViewBag.refresh = "<meta http-equiv=\"refresh\" content=\"" + phut + "; url=" + tblnews.Meta + "\">"; } ViewBag.dcDescription = "<meta name=\"DC.description\" content=\"" + tblnews.Description + "\" />"; string meta = ""; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Kangaroochinhhang.com/3/" + StringClass.NameToTag(tag) + "\" />"; meta += "<meta itemprop=\"name\" content=\"" + tblnews.Name + "\" />"; meta += "<meta itemprop=\"url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta itemprop=\"description\" content=\"" + tblnews.Description + "\" />"; meta += "<meta itemprop=\"image\" content=\"http://Kangaroochinhhang.com" + tblnews.Images + "\" />"; meta += "<meta property=\"og:title\" content=\"" + tblnews.Title + "\" />"; meta += "<meta property=\"og:type\" content=\"product\" />"; meta += "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta property=\"og:image\" content=\"http://Kangaroochinhhang.com" + tblnews.Images + "\" />"; meta += "<meta property=\"og:site_name\" content=\"http://Kangaroochinhhang.com\" />"; meta += "<meta property=\"og:description\" content=\"" + tblnews.Description + "\" />"; meta += "<meta property=\"fb:admins\" content=\"\" />"; ViewBag.Meta = meta; StringBuilder schame = new StringBuilder(); schame.Append("<script type=\"application/ld+json\">"); schame.Append("{"); schame.Append("\"@context\": \"http://schema.org\","); schame.Append("\"@type\": \"NewsArticle\","); schame.Append("\"headline\": \"" + tblnews.Description + "\","); schame.Append(" \"datePublished\": \"" + tblnews.DateCreate + "\","); schame.Append("\"image\": ["); schame.Append(" \"" + tblnews.Images + "\""); schame.Append(" ]"); schame.Append("}"); schame.Append("</script> "); ViewBag.schame = schame.ToString(); int iduser = int.Parse(tblnews.idUser.ToString()); ViewBag.user = db.tblUsers.First(p => p.id == iduser).UserName; string tab = tblnews.Tabs; string Tabsnews = ""; if (tab != null) { string[] mang = tab.Split(','); for (int i = 0; i < mang.Length; i++) { Tabsnews += " <a href=\"/TagNews/" + StringClass.NameToTag(mang[i]) + "\" title=\"" + mang[i] + "\">" + mang[i] + "</a>"; } ViewBag.tags = Tabsnews; } StringBuilder result = new StringBuilder(); var listIdNews = db.tblConnectManuToNews.Where(p => listId.Contains(p.idManu)).Select(p => p.idNews).ToList(); var listnews = db.tblNews.Where(p => listIdNews.Contains(p.id) && p.Active == true && p.id != id).OrderByDescending(p => p.DateCreate).Take(5).ToList(); if (listnews.Count > 0) { for (int j = 0; j < listnews.Count; j++) { result.Append(" <li><a href=\"/3/" + listnews[j].Tag + "\" title=\"" + listnews[j].Name + "\"><i class=\"fa fa-angle-right\" aria-hidden=\"true\"></i> " + listnews[j].Name + "</a><span>"); result.Append(" <i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> Viết ngày : " + listnews[j].DateCreate + " </span><li>"); } } ViewBag.result = result.ToString(); ViewBag.favicon = " <link href=\"" + manufactures.Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; ViewBag.nUrl = "<ol itemscope itemtype=\"http://schema.org/BreadcrumbList\"> <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"> <a itemprop=\"item\" href=\"http://Kangaroochinhhang.com\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> ›" + Urlnews(idmenu) + "</ol>"; int visit = int.Parse(tblnews.Visit.ToString()); if (visit > 0) { tblnews.Visit = tblnews.Visit + 1; db.SaveChanges(); } else { tblnews.Visit = tblnews.Visit + 1; db.SaveChanges(); } return(View(tblnews)); }
public ActionResult productDetail(string tag) { TblProduct ProductDetail = db.TblProduct.First(p => p.Tag == tag); int id = ProductDetail.Id; TblGroupProduct tblgroupProduct = db.TblGroupProduct.FirstOrDefault(p => p.Id == ProductDetail.IdCate.Value); var tblconfig = db.TblConfig.FirstOrDefault(); ViewBag.color = tblconfig.Color; int idmanu = int.Parse(db.TblConnectManuProduct.FirstOrDefault(p => p.IdCate == tblgroupProduct.Id).IdManu.ToString()); ViewBag.manuName = db.TblManufactures.FirstOrDefault(p => p.Id == idmanu).Name; ViewBag.Manu = "<li><span>Thương hiệu : Tân Á Đại Thành</span></li>"; ViewBag.favicon = " <link href=\"" + tblconfig.Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; ViewBag.Title = "<title>" + ProductDetail.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + ProductDetail.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + ProductDetail.Keyword + "\" /> "; ViewBag.imageog = "<meta property=\"og:image\" content=\"http://Bontana.vn" + ProductDetail.ImageLinkThumb + "\"/>"; ViewBag.titleog = "<meta property=\"og:title\" content=\"" + ProductDetail.Title + "\"/> "; ViewBag.site_nameog = "<meta property=\"og:site_name\" content=\"" + ProductDetail.Name + "\"/> "; ViewBag.urlog = "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\"/> "; ViewBag.descriptionog = "<meta property=\"og:description\" content=\"" + ProductDetail.Description + "\" />"; ViewBag.nUrl = "<ol itemscope itemtype=\"http://schema.org/BreadcrumbList\"> <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"> <a itemprop=\"item\" href=\"http://Bontana.vn\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> ›" + UrlProduct(tblgroupProduct.Id) + "</ol> "; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Bontana.vn/san-pham/" + ProductDetail.Tag + "\" />"; StringBuilder schame = new StringBuilder(); schame.Append("<script type=\"application/ld+json\">"); schame.Append("{"); schame.Append("\"@context\": \"http://schema.org\","); schame.Append("\"@type\": \"ProductArticle\","); schame.Append("\"headline\": \"" + ProductDetail.Description + "\","); schame.Append(" \"datePublished\": \"" + ProductDetail.DateCreate + "\","); schame.Append("\"image\": ["); schame.Append(" \"" + ProductDetail.ImageLinkThumb + "\""); schame.Append(" ]"); schame.Append("}"); schame.Append("</script> "); ViewBag.schame = schame.ToString(); var ListGroupCri = db.TblGroupCriteria.Where(p => p.IdCate == tblgroupProduct.Id).Select(p => p.IdCri).ToList(); var ListCri = db.TblCriteria.Where(p => ListGroupCri.Contains(p.Id) && p.Active == true).OrderBy(p => p.Ord).ToList(); StringBuilder chuoi = new StringBuilder(); #region [Lọc thuộc tính] for (int i = 0; i < ListCri.Count; i++) { int idCre = int.Parse(ListCri[i].Id.ToString()); var ListCr = (from a in db.TblConnectCriteria join b in db.TblInfoCriteria on a.IdCre equals b.Id where a.Idpd == id && b.IdCri == idCre && b.Active == true select new { b.Name, b.Url, b.Ord }).OrderBy(p => p.Ord).ToList(); if (ListCr.Count > 0) { chuoi.Append("<tr>"); chuoi.Append("<td>" + ListCri[i].Name + "</td>"); chuoi.Append("<td>"); int dem = 0; string num = ""; if (ListCr.Count > 1) { num = "⊹ "; } foreach (var item in ListCr) { if (item.Url != null && item.Url != "") { chuoi.Append("<a href=\"" + item.Url + "\" title=\"" + item.Name + "\">"); if (dem == 1) { chuoi.Append(num + item.Name); } else { chuoi.Append(num + item.Name); } dem = 1; chuoi.Append("</a>"); } else { if (dem == 1) { chuoi.Append(num + item.Name + "</br> "); } else { chuoi.Append(num + item.Name + "</br> "); } dem = 1; } } chuoi.Append("</td>"); chuoi.Append(" </tr>"); } } ViewBag.chuoi = chuoi.ToString(); int visit = int.Parse(ProductDetail.Visit.ToString()); if (visit > 0) { ProductDetail.Visit = ProductDetail.Visit + 1; db.SaveChanges(); } else { ProductDetail.Visit = ProductDetail.Visit + 1; db.SaveChanges(); } var listImages = db.TblImageProduct.Where(p => p.IdProduct == id).ToList(); StringBuilder chuoiimages = new StringBuilder(); if (listImages.Count > 0) { chuoiimages.Append("<li class=\"getImg" + ProductDetail.Id + "\"><a href=\"javascript:;\" onclick=\"javascript:return getImage('" + ProductDetail.ImageLinkDetail + "', 'getImg" + ProductDetail.Id + "')\" title=\"" + ProductDetail.Name + "\"><img src=\"" + ProductDetail.ImageLinkDetail + "\" alt=\"" + ProductDetail.Name + "\" /></a></li>"); for (int i = 0; i < listImages.Count; i++) { chuoiimages.Append("<li class=\"getImg" + listImages[i].Id + "\"><a href=\"javascript:;\" onclick=\"javascript:return getImage('" + listImages[i].Images + "', 'getImg" + listImages[i].Id + "')\" title=\"" + ProductDetail.Name + "\"><img src=\"" + listImages[i].Images + "\" alt=\"" + ProductDetail.Name + "\" /></a></li>"); } } ViewBag.chuoiimages = chuoiimages; ViewBag.hotline = db.TblConfig.First().HotlineIn; //load root StringBuilder chuoitag = new StringBuilder(); if (ProductDetail.Tabs != null) { string Chuoi = ProductDetail.Tabs; string[] Mang = Chuoi.Split(','); List <int> araylist = new List <int>(); for (int i = 0; i < Mang.Length; i++) { string tagsp = StringClass.NameToTag(Mang[i]); chuoitag.Append("<a href=\"/tag/" + tagsp + "\" title=\"" + Mang[i] + "\">" + Mang[i] + "</a>"); } } ViewBag.chuoitag = chuoitag; StringBuilder result = new StringBuilder(); result.Append("<div class=\"tearListProduct\">"); result.Append("<div class=\"contentListProductContent\">"); var listProduct = db.TblProduct.Where(p => p.Active == true && p.IdCate == tblgroupProduct.Id && p.Tag != tag).Take(6).OrderBy(p => p.Ord).ToList(); for (int j = 0; j < listProduct.Count; j++) { result.Append("<div class=\"tear\">"); result.Append("<div class=\"contentTear\">"); float price = float.Parse(listProduct[j].Price.ToString()); float pricesale = float.Parse(listProduct[j].PriceSale.ToString()); float phantram = 100 - ((pricesale * 100) / price); result.Append(" <div class=\"sale\">" + Convert.ToInt32(phantram) + "%</div>"); if (listProduct[j].Note != null && listProduct[j].Note != "") { result.Append("<div class=\"noteTear\">" + listProduct[j].Note + "</div>"); } result.Append("<div class=\"img\">"); result.Append("<a href=\"/san-pham/" + listProduct[j].Tag + "\" title=\"" + listProduct[j].Name + "\"><img src=\"" + listProduct[j].ImageLinkThumb + "\" alt=\"" + listProduct[j].Name + "\" /></a>"); result.Append(" </div>"); result.Append("<a href=\"/san-pham/" + listProduct[j].Tag + "\" title=\"" + listProduct[j].Name + "\" class=\"name\">" + listProduct[j].Name + "</a>"); result.Append("<div class=\"boxItem\">"); result.Append("<div class=\"boxPrice\">"); result.Append("<span class=\"priceSale\">" + string.Format("{0:#,#}", listProduct[j].PriceSale) + "đ</span>"); result.Append("<span class=\"price\">" + string.Format("{0:#,#}", listProduct[j].Price) + "đ</span>"); result.Append("</div>"); result.Append("<div class=\"boxSale\">"); result.Append("<a href=\"\" title=\"\"></a>"); result.Append("</div>"); result.Append("</div>"); result.Append(" </div>"); result.Append("</div>"); } result.Append("</div>"); result.Append("</div>"); ViewBag.resultLienquan = result.ToString(); #endregion return(View(ProductDetail)); }