private void bindImagesGrid() { if (ReferenceGuid != Guid.Empty) { var images = StoreImage.GetByReference(ReferenceGuid); grdImages.DataSource = images; grdImages.DataBind(); } }
private static ImageModel ConvertToImageModel(StoreImage storeImage) { ImageModel imageModel = new ImageModel { Id = storeImage.Id, Image = storeImage.ImageData, }; return(imageModel); }
public static StoreItem ConvertModelToStoreItem(StoreItemModel model) { if (model == null) { return(null); } List <StoreImage> StoreImages = new List <StoreImage>(); List <Specification> Specifications = new List <Specification>(); if (model.Images != null) { foreach (var imageData in model.Images) { StoreImage storeImage = new StoreImage { Id = imageData.Id, ImageData = imageData.Image, }; StoreImages.Add(storeImage); } } if (model.Specifications != null) { foreach (var specificationModel in model.Specifications) { Specification specification = new Specification { Id = Guid.NewGuid(), Name = specificationModel.Name, Description = specificationModel.Description }; Specifications.Add(specification); } } StoreItem storeItem = new StoreItem { Id = model.Id, Name = model.Name, Discription = model.Discription, Price = model.Price, DiscountPercentage = model.Discount, Brand = model.Brand, Images = StoreImages, InStock = model.InStock, Specification = Specifications }; return(storeItem); }
private void PopulateControls() { if (product == null) { return; } heading.Text = Server.HtmlEncode(product.Name); if (UserCanEditModule(moduleId)) { string editUrl = $"{SiteRoot}/WebStore/AdminProductEdit.aspx?pageid={pageId}&mid={moduleId}&prod={productGuid}"; string editLink = string.Format(displaySettings.ProductEditLinkFormat, editUrl, WebStoreResources.ProductEditHeadingTooltip, WebStoreResources.ProductEditHeading); heading.LiteralExtraMarkup += editLink; } litDescription.Text = displaySettings.ProductDetailDescriptionMarkupTop + product.Description + displaySettings.ProductDetailDescriptionMarkupBottom; MetaDescription = product.MetaDescription; MetaKeywordCsv = product.MetaKeywords; AdditionalMetaMarkup = product.CompiledMeta; //pnlOffers.CssClass = displaySettings.ProductDetailsOffersDivCssClass; if (product.TeaserFile.Length > 0) { lnkPreview.Text = product.Name; lnkPreview.NavigateUrl = teaserFileBaseUrl + product.TeaserFile; lnkPreview.Visible = true; string teaserFileExt = product.TeaserFile.Substring(product.TeaserFile.LastIndexOf('.')); var mediaExtensions = WebConfigSettings.JPlayerVideoFileExtensions.SplitOnCharAndTrim('|'); mediaExtensions.AddRange(WebConfigSettings.JPlayerAudioFileExtensions.SplitOnCharAndTrim('|')); if (mediaExtensions.Contains(teaserFileExt) && displaySettings.UsejPlayerForMediaTeasers) { jPlayerPanel.RenderPlayer = true; } } if (product.EnableRating) { //mojoRating rating = new mojoRating(); ((mojoRating)Rating).ContainerCssClass = displaySettings.ProductDetailsRatingPanelDivCssClass; ((mojoRating)Rating).ShowPrompt = true; ((mojoRating)Rating).ContentGuid = product.Guid; ((mojoRating)Rating).AllowFeedback = enableRatingComments; ((mojoRating)Rating).PromptText = WebStoreResources.RatingPrompt; ((mojoRating)Rating).Visible = true; } DataTable dtOffers = Offer.GetByProduct(product.Guid); rptOffers.DataSource = dtOffers; rptOffers.DataBind(); rptImages.DataSource = StoreImage.GetByReference(product.Guid); rptImages.DataBind(); }
private void grdImages_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridView grid = (GridView)sender; Guid guid = (Guid)grid.DataKeys[e.RowIndex].Value; StoreImage.Delete(guid); grdImages.EditIndex = -1; btnAddImage.Visible = true; bindImagesGrid(); upImages.Update(); }
public bool CreatStoreImg(int storeId, string imgUrl, int ImgTypeId) { StoreImage storeImage = new StoreImage() { ImageUrl = imgUrl, StoreImgTypeId = ImgTypeId, StoreDetailId = storeId, }; storeDb.CreateStoreImg(storeImage); return(true); }
public bool EditStoreImage(StoreImage storeImage) { try { sdb.Entry(storeImage).State = EntityState.Modified; sdb.SaveChanges(); return(true); } catch { return(false); } }
public bool AddStoreImage(StoreImage storeImage) { try { sdb.StoreImages.Add(storeImage); sdb.SaveChanges(); return(true); } catch { return(false); } }
public bool CreateStoreImg(StoreImage storeImage) { try { db.StoreImages.Add(storeImage); db.SaveChanges(); return(true); } catch { return(false); } }
private void grdImages_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridView grid = (GridView)sender; Guid guid = (Guid)grid.DataKeys[e.RowIndex].Value; TextBox txtImageUrl = (TextBox)grid.Rows[e.RowIndex].Cells[0].FindControl("txtImageUrl"); TextBox txtDisplayOrder = (TextBox)grid.Rows[e.RowIndex].Cells[0].FindControl("txtDisplayOrder"); TextBox txtAlt = (TextBox)grid.Rows[e.RowIndex].Cells[0].FindControl("txtAlt"); TextBox txtTitle = (TextBox)grid.Rows[e.RowIndex].Cells[0].FindControl("txtTitle"); StoreImage image; if (guid != Guid.Empty) { image = new StoreImage(guid); } else { image = new StoreImage { Guid = Guid.NewGuid(), StoreGuid = CacheHelper.GetCurrentSiteSettings().SiteGuid, ReferenceGuid = ReferenceGuid }; } image.ImageUrl = txtImageUrl.Text; image.DisplayOrder = Convert.ToInt32(txtDisplayOrder.Text); image.Alt = txtAlt.Text; image.Title = txtTitle.Text; image.Save(); grdImages.EditIndex = -1; btnAddImage.Visible = true; bindImagesGrid(); upImages.Update(); }
public JsonResult ImageUpload(ImageViewModel model) { dbFilesEntities1 db = new dbFilesEntities1(); int ImgId = 0; var Lat = "Latitude"; var Lon = "Longitude"; var file = model.ImageFile; byte[] Imagebyte = null; if (file != null) { //var fileName = Path.GetFileName(file.FileName); //var extention = Path.GetExtension(file.FileName); //var filenamewithoutextension = Path.GetFileNameWithoutExtension(file.FileName); file.SaveAs(Server.MapPath("/UploadImage/" + file.FileName)); BinaryReader reader = new BinaryReader(file.InputStream); Imagebyte = reader.ReadBytes(file.ContentLength); StoreImage img = new StoreImage(); img.Lat = Lat; img.Lon = Lon; img.ImgTitle = file.FileName; img.ImgByte = Imagebyte; img.ImgPath = "/UploadedImage/" + file.FileName; img.IsDelete = 0; db.StoreImages.Add(img); db.SaveChanges(); ImgId = img.ImgId; } return(Json(ImgId, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> UploadImage(UploadImageBindingModel model) { try { if (ModelState.IsValid) { //get current album name var album = _context.Albums.Where(a => a.Id == model.AlbumId).FirstOrDefault(); if (model.UploadImage.Length > 0) { var ext = Path.GetExtension(model.UploadImage.FileName).ToLowerInvariant(); if (string.IsNullOrEmpty(ext) || !Constants.permittedExtensions.Contains(ext)) { ModelState.AddModelError("InvoiceFile", "Invalid File Type!"); return(View());//todo } else { string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + "_" + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0') + "_" + DateTime.Now.Millisecond.ToString().PadLeft(4, '0') + ext; string filePath = Path.Combine(_configuration.GetValue <string>("CustomSettings:UploadPath"), album.AlbumFolderName, fileName); using (var stream = System.IO.File.Create(filePath)) { await model.UploadImage.CopyToAsync(stream); UploadImageHelper.ResizeAndSaveImage(stream, Path.Combine(_configuration.GetValue <string>("CustomSettings:UploadPath"), album.AlbumFolderName, "thumb", fileName)); } StoreImage image = new StoreImage() { AlbumId = album.Id, Title = model.Title, FileName = fileName, UploadDate = DateTime.Now, }; _context.StoreImages.Add(image); } } _context.SaveChanges(); return(RedirectToAction("Images", "Albums", new { id = album.Id })); } else { return(View(model)); } } catch { throw; } }
public override System.Xml.XmlDocument XmlSerialize() { System.Xml.XmlDocument document = base.XmlSerialize(); System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0]; #region Properties CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Version", Version.ToString()); CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FormId", FormId.ToString()); CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FormName", application.CoreObjectGetNameById("Form", formId)); CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "StoreImage", StoreImage.ToString()); #endregion #region Contents System.Xml.XmlNode componentsNode = document.CreateElement("Contents"); document.LastChild.AppendChild(componentsNode); foreach (Int32 currentContentIndex in content.Keys) { componentsNode.AppendChild(document.ImportNode(content [currentContentIndex].XmlSerialize().LastChild, true)); } #endregion return(document); }
public ImgsController(StoreImage imgService) { _imgService = imgService; }
public ActionResult Index(int ProductID, FormCollection collection) { var db = new DB(); var prod = db.StoreProducts.First(x => x.ID == ProductID); ViewBag.Product = prod; var list = db.StoreImages.Where(x => x.ProductID == ProductID).OrderBy(x => x.OrderNum).ToList(); if (collection["Image_New_Icon"].IsFilled() || collection["Image_New"].IsFilled()) { list.Add(new StoreImage() { Enabled = true /*, ID = 1, UrlPath = "/content/admin/apple.png"*/ }); } var add = collection.AllKeys.Any(x => x == "Apply_0"); if (add) { if (Request.Files.AllKeys.All(x => x != "Upload_0")) { ModelState.AddModelError("", "Необходимо выбрать изображение"); } else { var uf = Request.Files["Upload_0"]; var file = "/content/Catalog/" + prod.SlugOrId + Path.GetExtension(uf.FileName); if (System.IO.File.Exists(Server.MapPath(file))) { for (int i = 0; i < 100; i++) { file = "/content/Catalog/" + prod.SlugOrId + "-" + i + Path.GetExtension(uf.FileName); if (!System.IO.File.Exists(Server.MapPath(file))) { break; } } } uf.SaveAs(Server.MapPath(file)); var ni = new StoreImage() { Alt = collection["Alt_0"], Description = collection["Title_0"], UrlPath = file, /*Youtube = collection["Youtube_0"],*/ UrlPathThumbs = file, ProductID = prod.ID, Enabled = collection["Enabled_0"].ToBool(), OrderNum = db.StoreImages.Count() + 1 }; db.StoreImages.InsertOnSubmit(ni); db.SubmitChanges(); list = db.StoreImages.Where(x => x.ProductID == ProductID).OrderBy(x => x.OrderNum).ToList(); } } var delete = collection.AllKeys.Any(x => x.StartsWith("Delete_") && x != "Delete_0"); if (delete) { var id = collection.AllKeys.First(x => x.StartsWith("Delete_")).Replace("Delete_", "").ToInt(); var ifd = db.StoreImages.FirstOrDefault(x => x.ID == id); if (ifd != null) { db.StoreImages.DeleteOnSubmit(ifd); db.SubmitChanges(); list = db.StoreImages.Where(x => x.ProductID == ProductID).OrderBy(x => x.OrderNum).ToList(); } } var apply = collection.AllKeys.Any(x => x.StartsWith("Apply_") && x != "Apply_0"); if (apply) { var id = collection.AllKeys.First(x => x.StartsWith("Apply_")).Replace("Apply_", "").ToInt(); var ifu = db.StoreImages.FirstOrDefault(x => x.ID == id); if (ifu != null) { if (Request.Files.AllKeys.Any(x => x == "Upload_" + id)) { var file = Request.Files["Upload_" + id]; if (file != null && file.ContentLength > 0) { file.SaveAs(Server.MapPath(ifu.UrlPath)); } } /*ifu.Youtube = collection["Youtube_" + id];*/ if (Request.Files.AllKeys.Any(x => x == "UploadVideo_" + id)) { var file = Request.Files["UploadVideo_" + id]; if (file != null && file.ContentLength > 0) { if (!Directory.Exists(Server.MapPath("/content/Video"))) { Directory.CreateDirectory(Server.MapPath("/content/Video")); } var path = "/content/Video/" + file.FileName; /* * int cnt = 1; * while (System.IO.File.Exists(Server.MapPath(path))) * { * path = "/content/Video/" + Path.GetFileNameWithoutExtension(file.FileName) + "-" + cnt + * Path.GetExtension(file.FileName); * cnt++; * } */ file.SaveAs(Server.MapPath(path)); ifu.Youtube = path; } } ifu.Description = collection["Title_" + id]; ifu.Alt = collection["Alt_" + id]; ifu.Enabled = collection["Enabled_" + id].ToBool(); db.SubmitChanges(); list = db.StoreImages.Where(x => x.ProductID == ProductID).OrderBy(x => x.OrderNum).ToList(); } } var up = collection.AllKeys.Any(x => x.StartsWith("Up_") && x != "Up_0"); if (up) { var id = collection.AllKeys.First(x => x.StartsWith("Up_")).Replace("Up_", "").ToInt(); var if1 = db.StoreImages.FirstOrDefault(x => x.ID == id); var if2 = db.StoreImages.OrderBy(x => x.OrderNum).FirstOrDefault(x => x.OrderNum < if1.OrderNum); if (if2 != null && if1 != null) { var if1o = if1.OrderNum; if1.OrderNum = if2.OrderNum; if2.OrderNum = if1o; db.SubmitChanges(); list = db.StoreImages.Where(x => x.ProductID == ProductID).OrderBy(x => x.OrderNum).ToList(); } } var down = collection.AllKeys.Any(x => x.StartsWith("Down_") && x != "Down_0"); if (down) { var id = collection.AllKeys.First(x => x.StartsWith("Down_")).Replace("Down_", "").ToInt(); var if1 = db.StoreImages.FirstOrDefault(x => x.ID == id); var if2 = db.StoreImages.OrderBy(x => x.OrderNum).FirstOrDefault(x => x.OrderNum > if1.OrderNum); if (if2 != null && if1 != null) { var if1o = if1.OrderNum; if1.OrderNum = if2.OrderNum; if2.OrderNum = if1o; db.SubmitChanges(); list = db.StoreImages.Where(x => x.ProductID == ProductID).OrderBy(x => x.OrderNum).ToList(); } } return(View(list)); }
/// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void TbutQueryClick(object sender, DirectEventArgs e) { if (string.IsNullOrEmpty(this.TxtplateId.Text)) { Notice("信息提示", "请填写号牌号码!"); return; } Condition con = GetWhere(); if (con != null) { if (Session["userinfo"] != null) { con.UserName = (Session["userinfo"] as UserInfo).UserName; //用户名称 con.UserCode = (Session["userinfo"] as UserInfo).UserCode; //用户编号 } string ipaddress = Request.ServerVariables.Get("Remote_Addr").ToString(); if (ipaddress.Length < 9) { ipaddress = "127.0.0.1"; } con.UserIp = ipaddress; //用户Ip地址 con.Dyzgnmkmc = PasscarAllQuery.dyzgnmkmc; //功能模块名称 con.Dyzgnmkbh = PasscarAllQuery.dyzgnmkbh; //功能模块编号 dtPath = CreatePathQueryTable(); string xml = MyNet.Atmcs.Uscmcp.Bll.Common.GetPassCarXml(con, "10", "50"); string rexml = client.GetPassCarInfo(xml); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.LoadXml(rexml); } catch (Exception) { throw; } //allNum = Bll.Common.GetRowCount(xmlDoc); if (!string.IsNullOrEmpty(rexml)) { CXmlToDataTable(xmlDoc); if (dtPath != null && dtPath.Rows.Count > 0) { DataTable dt = MyNet.Atmcs.Uscmcp.Bll.Common.ChangColName(dtPath); StoreImage.DataSource = dt; StoreImage.DataBind(); } } //原来的 // DataTable dt = tgsDataInfo.GetAllPassCarInfo(GetWhere()); //if (dt != null && dt.Rows.Count > 0) //{ // dt = dataCommon.ChangeDataTablePoliceIp(dt, "col12", "", ""); // StoreImage.DataSource = dt; // StoreImage.DataBind(); //} //else //{ // Notice("信息提示", "未查询到任何符合条件的信息!"); //} } }
public bool EditStoreItem(StoreImage storeImage) { throw new NotImplementedException(); }