Beispiel #1
0
        public ActionResult Create([Bind(Include = "PostID,PTitle,Post_content,AdminID,Datepost,Status,ToppicID")] Post post, string linkImg)
        {
            StringBuilder sb = new StringBuilder();

            if (ModelState.IsValid)
            {
                string x = RandomNumber(1, 9999999).ToString();
                post.PostID   = x;
                post.Datepost = DateTime.Now;
                post.AdminID  = Session["AdminID"].ToString();
                post.Status   = "Disable";
                db.Posts.Add(post);
                db.SaveChanges();
                db = new ModelContext1();
                RepresentImage RIM = new RepresentImage();
                RIM.IMGID  = x;
                RIM.PostID = post.PostID;
                RIM.Image  = linkImg;
                db.RepresentImages.Add(RIM);
                db.SaveChanges();
                db = new ModelContext1();
                return(RedirectToAction("IndexDisable", "Posts"));
            }

            ViewBag.AdminID  = new SelectList(db.Admins, "AdminID", "Name", post.AdminID);
            ViewBag.ToppicID = new SelectList(db.Toppics, "ToppicID", "Toppic1", post.ToppicID);
            return(View(post));
        }
Beispiel #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            RepresentImage representImage = db.RepresentImages.Find(id);

            db.RepresentImages.Remove(representImage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "IMGID,PostID,Image")] RepresentImage representImage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(representImage).State = EntityState.Modified;
         db.SaveChanges();
         //return RedirectToAction("Index");
         return(RedirectToAction("Edit", "Posts", new { id = representImage.IMGID }));
     }
     ViewBag.PostID = new SelectList(db.Posts, "PostID", "PTitle", representImage.PostID);
     return(View(representImage));
 }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "IMGID,PostID,Image")] RepresentImage representImage)
        {
            if (ModelState.IsValid)
            {
                db.RepresentImages.Add(representImage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PostID = new SelectList(db.Posts, "PostID", "PTitle", representImage.PostID);
            return(View(representImage));
        }
Beispiel #5
0
        // GET: RepresentImages/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepresentImage representImage = db.RepresentImages.Find(id);

            if (representImage == null)
            {
                return(HttpNotFound());
            }
            return(View(representImage));
        }
Beispiel #6
0
        // GET: RepresentImages/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepresentImage representImage = db.RepresentImages.Find(id);

            if (representImage == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PostID = new SelectList(db.Posts, "PostID", "PTitle", representImage.PostID);
            return(View(representImage));
        }