public Picture PictureCreate(Item item, string route)
        {
            Picture picture = new Picture();
            picture.IID = item.IID;
            picture.Route = route;
            Add(picture);

            return picture;
        }
示例#2
0
 public Item GetItem(Picture picture)
 {
     return yikuData.Items.SingleOrDefault(i => picture.IID == i.IID);
 }
示例#3
0
 /// <summary>
 /// 用于向 Pictures EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToPictures(Picture picture)
 {
     base.AddObject("Pictures", picture);
 }
示例#4
0
 /// <summary>
 /// 创建新的 Picture 对象。
 /// </summary>
 /// <param name="pID">PID 属性的初始值。</param>
 /// <param name="route">Route 属性的初始值。</param>
 /// <param name="iID">IID 属性的初始值。</param>
 public static Picture CreatePicture(global::System.Int32 pID, global::System.String route, global::System.Int32 iID)
 {
     Picture picture = new Picture();
     picture.PID = pID;
     picture.Route = route;
     picture.IID = iID;
     return picture;
 }
 public bool PictureExist(Picture picture)
 {
     if (yikuData.Pictures.SingleOrDefault(p => p == picture) == null)
         return true;
     return false;
 }
示例#6
0
        public ActionResult EditImage(HttpPostedFileBase imgUpload, int id)
        {
            Picture pic = new Picture();
             if (ModelState.IsValid)
             {
                 if (imgUpload != null)
                 {

                     string fileName = Path.GetFileName(Guid.NewGuid().ToString() + imgUpload.FileName);
                     var filePath = Path.Combine(Request.MapPath("~/Content/Image/Items"), fileName );
                     imgUpload.SaveAs(filePath);//保存Img图片
                     pic.IID = id;
                     pic.Route = fileName;
                     yikuData.PictureRemoveAll(yikuData.GetItem(id));
                     yikuData.Add(pic);
                     yikuData.Save();
                 }
             }
             return RedirectToAction("Edit", "Item", new { ID = id });
        }