public ActionResult Edit(int id, Tbl_Blog category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(category.BImageFill.FileName);
                    string extension = Path.GetExtension(category.BImageFill.FileName);
                    fileName           = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    category.BlogImage = "~/BlogImg/" + fileName;
                    fileName           = Path.Combine(Server.MapPath("~/BlogImg/"), fileName);
                    category.BImageFill.SaveAs(fileName);

                    category.BlCreatedDate = DateTime.Now;

                    db.Entry(category).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                // TODO: Add update logic here

                return(View(category));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(Tbl_Blog category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(category.BImageFill.FileName);
                    string extension = Path.GetExtension(category.BImageFill.FileName);
                    fileName           = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    category.BlogImage = "~/BlogImg/" + fileName;
                    fileName           = Path.Combine(Server.MapPath("~/BlogImg/"), fileName);
                    category.BImageFill.SaveAs(fileName);

                    category.BlCreatedDate = DateTime.Now;

                    //int temp = (int)(Session["BId"]);
                    //category.BId = (int)(Session["BId"]);

                    db.Tbl_Blog.Add(category);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                // TODO: Add insert logic here
                return(View(category));
            }
            catch
            {
                return(View());
            }
        }
예제 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tbl_Blog tbl_Blog = db.Tbl_Blog.Find(id);

            db.Tbl_Blog.Remove(tbl_Blog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
 public ActionResult Edit([Bind(Include = "BlogID,BlogTitle,BlogContent,UserID,CreatedDate,RatingPoint,NumOfRating,CategoryID")] Tbl_Blog tbl_Blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.Tbl_Category, "CategoryID", "CategoryName", tbl_Blog.CategoryID);
     ViewBag.UserID     = new SelectList(db.Tbl_User, "UserID", "Username", tbl_Blog.UserID);
     return(View(tbl_Blog));
 }
예제 #5
0
 public ActionResult Rate(int id, int star)
 {
     if (Session["Blog" + id] == null)
     {
         Tbl_Blog blog = db.Tbl_Blog.Find(id);
         blog.NumOfRating    += 1;
         blog.RatingPoint    += star;
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         Session["Blog" + id] = 1;
     }
     return(RedirectToAction("Details/" + id));
 }
예제 #6
0
        // GET: Blog/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Blog tbl_Blog = db.Tbl_Blog.Find(id);

            if (tbl_Blog == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_Blog));
        }
예제 #7
0
        protected void BtnKaydet_Click(object sender, EventArgs e)
        {
            Tbl_Blog t = new Tbl_Blog();

            t.BLOGBASLIK   = TxtBaslik.Text;
            t.BLOGGORSEL   = TxtGorsel.Text;
            t.BLOGICERIK   = TxtIcerik.Text;
            t.BLOGTARIH    = DateTime.Parse(TxtTarih.Text);
            t.BLOGTUR      = byte.Parse(DropDownList1.SelectedValue);
            t.BLOGKATEGORI = byte.Parse(DropDownList2.SelectedValue);
            db.Tbl_Blog.Add(t);
            db.SaveChanges();
            Response.Redirect("Bloglar.aspx");
        }
        // GET: AdminBlog/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Blog cat = db.Tbl_Blog.Find(id);

            if (cat == null)
            {
                return(HttpNotFound());
            }
            return(View(cat));
        }
예제 #9
0
        // GET: Blog/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Blog tbl_Blog = db.Tbl_Blog.Find(id);

            if (tbl_Blog == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryID = new SelectList(db.Tbl_Category, "CategoryID", "CategoryName", tbl_Blog.CategoryID);
            ViewBag.UserID     = new SelectList(db.Tbl_User, "UserID", "Username", tbl_Blog.UserID);
            return(View(tbl_Blog));
        }
        // GET: AdminBlog/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Blog cat = db.Tbl_Blog.Find(id);

            db.Tbl_Blog.Remove(cat);
            db.SaveChanges();
            if (cat == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index"));
        }
예제 #11
0
        public ActionResult Create([Bind(Include = "BlogID,BlogTitle,BlogContent,UserID,CreatedDate,RatingPoint,NumOfRating,CategoryID")] Tbl_Blog tbl_Blog)
        {
            if (ModelState.IsValid)
            {
                tbl_Blog.NumOfRating = 0;
                tbl_Blog.RatingPoint = 0;
                tbl_Blog.CreatedDate = DateTime.Now;
                tbl_Blog.UserID      = int.Parse(Session["UserID"].ToString());
                db.Tbl_Blog.Add(tbl_Blog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Tbl_Category, "CategoryID", "CategoryName", tbl_Blog.CategoryID);
            ViewBag.UserID     = new SelectList(db.Tbl_User, "UserID", "Username", tbl_Blog.UserID);
            return(View(tbl_Blog));
        }