public ActionResult UpdateLogo(string logourl) { var footer = db.FooterLogoes.FirstOrDefault(); if (footer == null) { footer = new FooterLogo(); if (logourl != null && logourl != "") { footer.logoimg = logourl; db.FooterLogoes.Add(footer); db.SaveChanges(); return(Json(1)); } } else if (logourl != null && logourl != "") { footer.logoimg = logourl; db.SaveChanges(); return(Json(1)); } else { return(Json(0)); } return(Json(0)); }
public ActionResult FooterEmployer(string html) { var footer = db.FooterLogoes.FirstOrDefault(); if (footer == null) { footer = new FooterLogo(); if (html != null && html != "") { footer.footeremployer = html; db.FooterLogoes.Add(footer); db.SaveChanges(); return(Json(1)); } } else if (html != null && html != "") { footer.footeremployer = html; db.SaveChanges(); return(Json(1)); } else { return(Json(0)); } return(Json(0)); }
public FooterLogo MountFooterLogo(List <string> logoImagesPaths) { List <Image> _logos = new List <Image>(); foreach (var logoPath in logoImagesPaths) { _logos.Add( new Image() { Source = ImageSource.FromUri(new Uri(logoPath)) }); } FooterLogo footerLogo = new FooterLogo { logos = _logos, //DEFINIÇÃO DE LINHA grid = new Grid() { RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, }, } }; //DEFINIÇÕES DE COLUNAS footerLogo.grid.ColumnDefinitions = new ColumnDefinitionCollection(); foreach (var logoPaths in logoImagesPaths) { footerLogo.grid.ColumnDefinitions .Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); } int colunaFooter = 0; foreach (var fl in _logos) { footerLogo.grid.Children.Add(fl); Grid.SetColumn(fl, colunaFooter); colunaFooter++; } footerLogo.Content = footerLogo.grid; return(footerLogo); }
public async Task <IActionResult> Create([Bind("UploadLogo,PhotoLogo,Id,UploadCopyright,PhotoCopyright")] FooterLogo footerLogo) { if (footerLogo.UploadLogo == null) { ModelState.AddModelError("UploadLogo", "The Photo field is required."); } else { if (footerLogo.UploadLogo.ContentType != "image/jpeg" && footerLogo.UploadLogo.ContentType != "image/png" && footerLogo.UploadLogo.ContentType != "image/gif") { ModelState.AddModelError("UploadLogo", "You can only download png, jpg or gif file"); } if (footerLogo.UploadLogo.Length > 1048576) { ModelState.AddModelError("UploadLogo", "The file size can be a maximum of 1 MB"); } } if (footerLogo.UploadCopyright == null) { ModelState.AddModelError("UploadCopyright", "The Photo field is required."); } else { if (footerLogo.UploadCopyright.ContentType != "image/jpeg" && footerLogo.UploadCopyright.ContentType != "image/png" && footerLogo.UploadCopyright.ContentType != "image/gif") { ModelState.AddModelError("UploadCopyright", "You can only download png, jpg or gif file"); } if (footerLogo.UploadCopyright.Length > 1048576) { ModelState.AddModelError("UploadCopyright", "The file size can be a maximum of 1 MB"); } } if (ModelState.IsValid) { var fileName = _fileManager.Upload(footerLogo.UploadLogo); footerLogo.PhotoLogo = fileName; var secondFaleName = _fileManager.Upload(footerLogo.UploadCopyright); footerLogo.PhotoCopyright = secondFaleName; _context.FooterLogos.Add(footerLogo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(footerLogo)); }
public async Task <IActionResult> Edit(int?id, [Bind("UploadLogo,PhotoLogo,Id,UploadCopyright,PhotoCopyright")] FooterLogo footerLogo) { if (id != footerLogo.Id) { return(NotFound()); } if (footerLogo.UploadCopyright == null) { ModelState.AddModelError("UploadCopyright", "The Photo field is required."); } if (ModelState.IsValid) { try { if (footerLogo.UploadLogo != null) { if (footerLogo.UploadLogo.ContentType != "image/jpeg" && footerLogo.UploadLogo.ContentType != "image/png" && footerLogo.UploadLogo.ContentType != "image/gif") { ModelState.AddModelError("UploadLogo", "You can only download png, jpg or gif file"); return(View(footerLogo)); } if (footerLogo.UploadLogo.Length > 1048576) { ModelState.AddModelError("UploadLogo", "The file size can be a maximum of 1 MB"); return(View(footerLogo)); } var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", footerLogo.PhotoLogo); _fileManager.Delete(oldFile); var fileName = _fileManager.Upload(footerLogo.UploadLogo, "wwwroot/uploads"); footerLogo.PhotoLogo = fileName; } if (footerLogo.UploadCopyright != null) { if (footerLogo.UploadCopyright.ContentType != "image/jpeg" && footerLogo.UploadCopyright.ContentType != "image/png" && footerLogo.UploadCopyright.ContentType != "image/gif") { ModelState.AddModelError("UploadCopyright", "You can only download png, jpg or gif file"); return(View(footerLogo)); } if (footerLogo.UploadCopyright.Length > 1048576) { ModelState.AddModelError("UploadCopyright", "The file size can be a maximum of 1 MB"); return(View(footerLogo)); } var secondOldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", footerLogo.PhotoCopyright); _fileManager.Delete(secondOldFile); var secondFileName = _fileManager.Upload(footerLogo.UploadCopyright, "wwwroot/uploads"); footerLogo.PhotoCopyright = secondFileName; } _context.Update(footerLogo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FooterLogoExsist(footerLogo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(footerLogo)); }
/// <summary> /// 获取尾部的信息 /// </summary> /// <param name="indexContent">头部,轮播图,尾部</param> /// <returns></returns> public static string GetFooter(List <webmaster> indexContent) { FooterLogo footerLogo = new FooterLogo(); ProductService proService = new ProductService(); AboutUs aboutUs = new AboutUs(); CommonProblems commonProblems = new CommonProblems(); Contact contact = new Contact(); RemarkFooter remarkFooters = new RemarkFooter(); List <FooterLogo> footersList = new List <FooterLogo>(); List <ProductService> productsList = new List <ProductService>(); List <AboutUs> aboutUsList = new List <AboutUs>(); List <CommonProblems> commonProblemsList = new List <CommonProblems>(); List <Contact> contactsList = new List <Contact>(); List <RemarkFooter> remarkFootList = new List <RemarkFooter>(); IndexAllFooter indexAllFooter = new IndexAllFooter(); string footerJsonTxt = null; if (indexContent != null) { foreach (var item in indexContent) { if (item != null) { if (item.vcName == "footerLogo") { footerLogo.Logo = item.vcContent; footersList.Add(footerLogo); indexAllFooter.footerLogo = footersList; } if (item.vcName == "nav") { JObject navs = (JObject)JsonConvert.DeserializeObject(item.vcContent);//将数据进行序列化 //检查 //产品服务 proService.productService = Convert.ToString(navs["productService"]) != null?Convert.ToString(navs["productService"]) : ""; proService.teamApply = Convert.ToString(navs["teamApply"]) != null?Convert.ToString(navs["teamApply"]) : ""; proService.honorApply = Convert.ToString(navs["honorApply"]) != null?Convert.ToString(navs["honorApply"]) : ""; proService.activeApply = Convert.ToString(navs["activeApply"]) != null?Convert.ToString(navs["activeApply"]) : ""; proService.perfectinformation = Convert.ToString(navs["perfectinformation"]) != null?Convert.ToString(navs["perfectinformation"]) : ""; productsList.Add(proService); indexAllFooter.proService = productsList; //产品服务结束 //关于我们 aboutUs.teamIntroduce = Convert.ToString(navs["teamIntroduce"]) != null?Convert.ToString(navs["teamIntroduce"]) : ""; aboutUs.joinUs = Convert.ToString(navs["joinUs"]) != null?Convert.ToString(navs["joinUs"]) : ""; aboutUs.problemBack = Convert.ToString(navs["problemBack"]) != null?Convert.ToString(navs["problemBack"]) : ""; aboutUsList.Add(aboutUs); indexAllFooter.aboutUs = aboutUsList; //关于我们结束 //常见问题 commonProblems.UnableLogin = Convert.ToString(navs["UnableLogin"]) != null?Convert.ToString(navs["UnableLogin"]) : ""; commonProblems.UnableRegister = Convert.ToString(navs["UnableRegister"]) != null?Convert.ToString(navs["UnableRegister"]) : ""; commonProblemsList.Add(commonProblems); indexAllFooter.comProblems = commonProblemsList; //常见问题结束 //BarQ群 contact.qqGroup = Convert.ToString(navs["qqGroup"]) != null?Convert.ToString(navs["qqGroup"]) : ""; contactsList.Add(contact); indexAllFooter.contacts = contactsList; //BarQ群结束 } if (item.vcName == "footer") { JObject footers = (JObject)JsonConvert.DeserializeObject(item.vcContent);//将数据进行序列化 //底部备注 remarkFooters.copyRight = Convert.ToString(footers["copyRight"]) != null?Convert.ToString(footers["copyRight"]) : ""; remarkFooters.address = Convert.ToString(footers["address"]) != null?Convert.ToString(footers["address"]) : ""; remarkFooters.record = Convert.ToString(footers["record"]) != null?Convert.ToString(footers["record"]) : ""; remarkFooters.maintenance = Convert.ToString(footers["maintenance"]) != null?Convert.ToString(footers["maintenance"]) : ""; remarkFootList.Add(remarkFooters); indexAllFooter.remarkFoots = remarkFootList; //底部备注结束 } } } footerJsonTxt = JsonConvert.SerializeObject(indexAllFooter, Newtonsoft.Json.Formatting.Indented); //footerJsonTxt = ClearCharacter(footerJsonTxt); } return(footerJsonTxt);//返回整个底部信息 }