public ActionResult Upload(long Id, HttpPostedFileBase file) { string path = Server.MapPath("~/imgRepo/PostRepo/" + Id + file.FileName); PostPictures p = new PostPictures(); p.PostId = Id; p.FileName = Id + file.FileName; db.PostPicture.Add(p); db.SaveChanges(); file.SaveAs(path); return(RedirectToAction("Index", "News")); }
public int AddPosts(PostPictures item) { context.PostPicture.Add(item); return(context.SaveChanges()); }