示例#1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the BrandItemImage EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBrandItemImage(BrandItemImage brandItemImage)
 {
     base.AddObject("BrandItemImage", brandItemImage);
 }
示例#2
0
        public ActionResult EditImagesBlock(BrandItem model)
        {
            using (var context = new SiteContainer())
            {
                var brandItem = context.BrandItem.Include("Brand").First(b => b.Id == model.Id);
                var brand = context.Brand.Include("BrandGroup").First(b => b.Id == model.BrandId);
                TryUpdateModel(brandItem, new[] {"SortOrder"});

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file == null) continue;
                    if (string.IsNullOrEmpty(file.FileName)) continue;

                    var ci = new BrandItemImage();
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                    string filePath = Server.MapPath("~/Content/Images");

                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500);

                    ci.ImageSource = fileName;
                    brandItem.BrandItemImages.Add(ci);
                }

                context.SaveChanges();
                
                return RedirectToAction("BrandDetails", "Home", new { area = "BrandCatalogue", brandGroup = brand.BrandGroup.Name, id = brand.Name });
            }
        }
示例#3
0
 /// <summary>
 /// Create a new BrandItemImage object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="imageSource">Initial value of the ImageSource property.</param>
 /// <param name="brandItemId">Initial value of the BrandItemId property.</param>
 public static BrandItemImage CreateBrandItemImage(global::System.Int32 id, global::System.String imageSource, global::System.Int32 brandItemId)
 {
     BrandItemImage brandItemImage = new BrandItemImage();
     brandItemImage.Id = id;
     brandItemImage.ImageSource = imageSource;
     brandItemImage.BrandItemId = brandItemId;
     return brandItemImage;
 }