Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="picture"></param>
 /// <returns></returns>
 public PictureEntity Add(PictureEntity picture)
 {
     using (Db.Context)
     {
         try { Db.Context.Attach(picture); } catch { }
         return(PictureManager.Add(picture));
     }
 }
Exemplo n.º 2
0
        public ActionResult AfterCreate(Picture picture)
        {
            HttpPostedFileBase file = Request.Files["image"];

            if (picture != null)
            {
                if (file != null)
                {
                    string filePath     = file.FileName;
                    string fileName     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                    string serverpath   = Server.MapPath(@"\images\pictures\") + fileName;
                    string relativepath = @"/images/pictures/" + fileName;
                    file.SaveAs(serverpath);
                    picture.Pic_Pic = relativepath;
                }
                Stream stream = file.InputStream;
                System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
                int Iwidth  = image.Width;
                int Iheight = image.Height;
                picture.Pic_Time   = DateTime.Now;
                picture.UID        = Convert.ToInt32(Session["UID"].ToString());
                picture.Pic_Width  = Iwidth;
                picture.Pic_Height = Iheight;
                Picture addpicture = new Picture
                {
                    UID        = picture.UID,
                    Pic_Pic    = picture.Pic_Pic,
                    TID        = picture.TID,
                    Pic_Mes    = picture.Pic_Mes,
                    Pic_Time   = picture.Pic_Time,
                    Pic_Height = picture.Pic_Height,
                    Pic_Width  = picture.Pic_Width
                };
                var temp = pm.Add(addpicture);
                if (temp == true)
                {
                    return(Content("<script>alert('上传成功!');window.open('" + Url.Action("Index", "Picture") + "','_self');</script>"));
                }
                else
                {
                    return(Content("上传失败"));
                }
            }
            ViewBag.picturetype = new SelectList(ptm.GetAll(), "Type_ID", "Name");
            return(View());
        }
Exemplo n.º 3
0
 // POST: api/Picture
 public void Post([FromBody] CreatePicture create)
 {
     manager.Add(create);
 }