示例#1
0
        public ActionResult AddBlog(blog b, HttpPostedFileBase[] Resim, bool?SSS)
        {
            b.CreatedDate = DateTime.Now;
            b.ReadCount   = 0;
            b.SSS         = SSS;
            db.blogs.Add(b);
            db.SaveChanges();

            if (Resim != null)
            {
                foreach (HttpPostedFileBase item in Resim)
                {
                    if (item != null)
                    {
                        fotograf f = new fotograf();
                        f.BlogId = b.Id;
                        f.Path   = ResimBelgeEkle(item);
                        db.fotografs.Add(f);
                        db.SaveChanges();
                    }
                }
            }



            ViewBag.SSS   = SSS;
            ViewBag.Mesaj = " * Başarıyla Eklenmiştir..";
            return(View());
        }
 public JsonResult eliminarBlog(long blogID)
 {
     try
     {
         long userId = (long)Session["USER_ID"];
         blog blog   = entities.blogs.Find(blogID);
         List <BlogUserLike> listBlog = entities.BlogUserLikes.Where(x => x.IDBlog == blog.id).ToList();
         entities.BlogUserLikes.RemoveRange(listBlog);
         entities.SaveChanges();
         List <blogcomment> listBlogCome = entities.blogcomments.Where(x => x.blog_id == blog.id).ToList();
         entities.blogcomments.RemoveRange(listBlogCome);
         entities.blogs.Remove(blog);
         entities.SaveChanges();
         return(Json(new
         {
             result = "success"
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             result = "error",
             exception = ex.Message
         }));
     }
 }
示例#3
0
        public HttpResponseMessage updateBlog(blog blogdetail)
        {
            Blog.Update(blogdetail);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
示例#4
0
        //
        // GET: /home/

        public ActionResult Index()
        {
            blog [] b = new blog[3];
            b[0] = new blog();
            b[1] = new blog();
            b[2] = new blog();

            b[0].name = "Google";
            b[0].link = "http://www.google.com.pk";
            b[1].name = "YAHOO!";
            b[1].link = "http://www.yahoo.com";
            b[2].name = "Gmail";
            b[2].link = "http://www.gmail.com";

            List <blog> li = new List <blog>();

            for (int i = 0; i < b.Length; i++)
            {
                li.Add(b[i]);
            }



            return(View(li));
        }
示例#5
0
        public ActionResult EditBlog(blog bl, HttpPostedFileBase[] Resim)
        {
            blog b = db.blogs.Find(bl.Id);

            b.Title    = bl.Title;
            b.Text     = bl.Text;
            b.Category = bl.Category;

            if (Resim != null)
            {
                foreach (HttpPostedFileBase item in Resim)
                {
                    if (item != null)
                    {
                        fotograf f = new fotograf();
                        f.BlogId = b.Id;
                        f.Path   = ResimBelgeEkle(item);
                        db.fotografs.Add(f);
                        db.SaveChanges();
                    }
                }
            }



            db.SaveChanges();

            ViewBag.Mesaj = " * Başarıyla Güncellenmiştir..";
            return(View(b));
        }
示例#6
0
        public HttpResponseMessage Post([FromBody] JObject value)
        {
            blog        blogadd     = new blog();
            blogBinding blogBinding = new blogBinding();

            blogadd.BlogTitle   = value["title"].ToString();
            blogadd.BlogContent = value["content"].ToString();
            blogadd.Blogdate    = DateTime.Now.ToString("G");
            db.blog.Add(blogadd);
            db.SaveChanges();


            string name   = value["member"].ToString();
            var    nameID = db.memberdb.FirstOrDefault(p => p.mb_employeeName == name);

            blogBinding.Memberdb_ID = nameID.mb_ID;
            blogBinding.Blog_ID     = blogadd.Blog_ID;
            db.blogBinding.Add(blogBinding);
            db.SaveChanges();


            var result = new
            {
                STATUS = true,
                MSG    = "成功",
            };

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
示例#7
0
        public ActionResult Create([Bind(Include = "id,title,photo,date,category_id,dec,text")] blog blog, HttpPostedFileBase photo)
        {
            if (ModelState.IsValid)
            {
                if (photo.ContentType == "image/jpeg" || photo.ContentType == "image/png" || photo.ContentType == "image/gif")
                {
                    //WebImage img = new WebImage(photo.InputStream);

                    DateTime now      = DateTime.Now;
                    string   fileName = now.ToString("yyyyMdHms") + Path.GetFileName(photo.FileName);
                    string   path     = Path.Combine(Server.MapPath("~/Uploads"), fileName);
                    photo.SaveAs(path);
                    //if (img.Width > 1000)
                    //    img.Resize(500, 500);
                    //img.Save(path);
                    blog.photo = fileName;
                    blog.date  = now;
                    db.blogs.Add(blog);
                    db.SaveChanges();
                }
                else
                {
                    ViewBag.category_id = new SelectList(db.blog_category, "id", "name");
                    ViewBag.Message     = "You can only jpg,png or gif file upload";
                    return(View());
                }
            }
            else
            {
                ViewBag.category_id = new SelectList(db.blog_category, "id", "name");
                ViewBag.Message     = "Errorrr";
                return(View());
            }
            return(RedirectToAction("Index"));
        }
示例#8
0
        public IActionResult writeBlog([FromBody] BlogInfo Blog)
        {
            var nowblog = new blog
            {
                b_date = DateTime.Now,
                b_id   = (context.tableCount.Find(1).blog + 1).ToString(),
                b_text = Blog.content,
                b_type = "tt"
            };

            context.blog.Add(nowblog);
            context.SaveChanges();
            //添加blog数量
            var tableCount = context.tableCount.Find(1);

            tableCount.blog += 1;
            context.tableCount.Attach(tableCount);
            context.SaveChanges();
            //添加联系集
            var newOwnBlog = new ownBlog
            {
                u_id = Blog.userId,
                b_id = (context.tableCount.Find(1).blog).ToString()
            };

            context.ownBlog.Add(newOwnBlog);
            context.SaveChanges();
            return(Ok(new
            {
                Success = true,
                msg = "Operation Done"
            }));
        }
示例#9
0
        public ActionResult Save(int?id, Commenting comments, string title)
        {
            var blog = new blog();

            if (id.HasValue)
            {
                blog = MASTERdomain.blogs.SingleOrDefault(x => x.id == id.Value);
                if (blog == null)
                {
                    return(RedirectToAction("NotFound", "Error", new { area = "" }));
                }
            }
            else
            {
                // TODO: allow blog handle to be editable
                var    perma  = title.ToPerma();
                string perma1 = perma;
                if (db.blogs.Count(x => x.permalink == perma1 &&
                                   x.subdomainid == subdomainid.Value) != 0)
                {
                    perma = string.Format("{0}-{1}", db.blogs.Max(x => x.id) + 1, perma);
                }
                blog.permalink   = perma.ToMaxLength(100);
                blog.subdomainid = subdomainid.Value;
                MASTERdomain.blogs.Add(blog);
            }

            blog.comments = (short)comments;
            blog.title    = title;
            blog.updated  = DateTime.UtcNow;

            repository.Save();

            return(Json("Blog save successfully".ToJsonOKMessage()));
        }
示例#10
0
        public IHttpActionResult Postblog(blog blog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.blogs.Add(blog);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (blogExists(blog.UserId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = blog.UserId }, blog));
        }
示例#11
0
        public IHttpActionResult Putblog(string id, blog blog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != blog.UserId)
            {
                return(BadRequest());
            }

            db.Entry(blog).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!blogExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult verblog(long?blogID)
        {
            if (Session["USER_ID"] != null)
            {
                if (blogID != null)
                {
                    long userId       = (long)Session["USER_ID"];
                    long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                    List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                    user             curUser          = entities.users.Find(userId);
                    blog             blog             = entities.blogs.Find(blogID);
                    verblogViewModel viewModel        = new verblogViewModel();
                    viewModel.side_menu     = "comunicaciones";
                    viewModel.side_sub_menu = "comunicaciones";

                    viewModel.curUser         = curUser;
                    viewModel.viewBlog        = blog;
                    viewModel.Content         = blogID.ToString();
                    viewModel.blogID          = Convert.ToInt64(blogID);
                    viewModel.blogcommentList = entities.blogcomments.Where(m => m.blog_id == blogID).ToList();
                    viewModel.pubTaskList     = ep.GetNotifiTaskList(userId);
                    viewModel.pubMessageList  = pubMessageList;
                    viewModel.messageCount    = ep.GetUnreadMessageCount(pubMessageList);
                    return(View(viewModel));
                }
                else
                {
                    return(Redirect(Url.Action("NotFound", "Error")));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
示例#13
0
        public ActionResult DeleteConfirmed(int id)
        {
            blog blog = db.blogs.Find(id);

            db.blogs.Remove(blog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult verblog(long?blogID)
 {
     if (Session["USER_ID"] != null)
     {
         if (Session["CURRENT_COMU"] != null)
         {
             if (blogID != null)
             {
                 long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                 blog blog         = entities.blogs.Where(x => x.id == blogID && x.community_id == communityAct || x.id == blogID && x.user.role == 3).FirstOrDefault();
                 if (blog != null)
                 {
                     try
                     {
                         long userId = (long)Session["USER_ID"];
                         List <ShowMessage> pubMessageList = ep.GetChatMessages(userId);
                         user             curUser          = entities.users.Find(userId);
                         verblogViewModel viewModel        = new verblogViewModel();
                         communityList                    = ep.GetCommunityList(userId);
                         viewModel.communityList          = communityList;
                         viewModel.side_menu              = "comunicaciones";
                         viewModel.side_sub_menu          = "comunicaciones_blog";
                         viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                         viewModel.curUser                = curUser;
                         viewModel.viewBlog               = blog;
                         viewModel.Content                = blogID.ToString();
                         viewModel.blogID                 = Convert.ToInt64(blogID);
                         viewModel.blogcommentList        = entities.blogcomments.Where(m => m.blog_id == blogID).ToList();
                         viewModel.pubTaskList            = ep.GetNotifiTaskList(userId);
                         viewModel.pubMessageList         = pubMessageList;
                         viewModel.messageCount           = ep.GetUnreadMessageCount(pubMessageList);
                         return(View(viewModel));
                     }
                     catch (Exception ex)
                     {
                         return(Redirect(Url.Action("error", "control", new { area = "coadmin", Error = "Ver blog: " + ex.Message })));
                     }
                 }
                 else
                 {
                     return(Redirect(Url.Action("blog", "comunicaciones", new { area = "coadmin", Error = "No existe ese elemento" })));
                 }
             }
             else
             {
                 return(Redirect(Url.Action("blog", "comunicaciones", new { area = "coadmin" })));
             }
         }
         else
         {
             return(Redirect(Url.Action("blog", "comunicaciones", new { area = "coadmin", Error = "No permitido. Usted no administra ninguna comunidad. Comuníquese con el Webmaster..." })));
         }
     }
     else
     {
         return(Redirect(ep.GetLogoutUrl()));
     }
 }
示例#15
0
 public ActionResult agregarcomentario(long?blogID)
 {
     if (Session["USER_ID"] != null)
     {
         if (Session["CURRENT_COMU"] != null)
         {
             if (blogID != null)
             {
                 long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]);
                 blog blogs        = entities.blogs.Where(x => x.id == blogID && x.community_id == communityAct).FirstOrDefault();
                 if (blogs != null)
                 {
                     try
                     {
                         long userId  = (long)Session["USER_ID"];
                         user curUser = entities.users.Find(userId);
                         List <ShowMessage>         pubMessageList = ep.GetChatMessages(userId);
                         agregarComentarioViewModel viewModel      = new agregarComentarioViewModel();
                         titulosList                      = ep.GetTitulosByTitular(userId);
                         listComunities                   = ep.GetCommunityListByTitular(titulosList);
                         viewModel.communityList          = listComunities;
                         viewModel.side_menu              = "comunicaciones";
                         viewModel.side_sub_menu          = "comunicaciones_agregarcomentario";
                         viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                         viewModel.curUser                = curUser;
                         viewModel.blogID                 = Convert.ToInt64(blogID);
                         viewModel.pubTaskList            = ep.GetNotifiTaskList(userId);
                         viewModel.pubMessageList         = pubMessageList;
                         viewModel.messageCount           = ep.GetUnreadMessageCount(pubMessageList);
                         return(View(viewModel));
                     }
                     catch (Exception ex)
                     {
                         return(Redirect(Url.Action("error", "control", new { Error = "Agregar comentario blog: ", ex.Message })));
                     }
                 }
                 else
                 {
                     return(Redirect(Url.Action("blog", "comunicaciones", new { Error = "No existe ese elemento" })));
                 }
             }
             else
             {
                 return(Redirect(Url.Action("blog", "comunicaciones")));
             }
         }
         else
         {
             return(Redirect(Url.Action("blog", "comunicaciones", new { Error = "No puede agregar comentarios. Usted no pertenece ninguna comunidad" })));
         }
     }
     else
     {
         return(Redirect(ep.GetLogoutUrl()));
     }
 }
示例#16
0
 public ActionResult Edit([Bind(Include = "BlogID,Name")] blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(blog));
 }
示例#17
0
文件: Blog.cs 项目: seanlinmt/tradelr
 public Blog(blog blog)
 {
     id               = blog.id;
     title            = blog.title;
     handle           = blog.permalink;
     url              = blog.ToLiquidUrl();
     articles         = blog.articles.Where(x => x.published.HasValue).ToLiquidModel().ToList();
     comments_enabled = (Commenting)blog.comments != Commenting.OFF;
     moderated        = (Commenting)blog.comments == Commenting.MODERATED;
 }
示例#18
0
 public ActionResult Edit([Bind(Include = "blog_id,blog_article,blogger_name,blogger_email,blogger_image,blog_image")] blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(blog));
 }
示例#19
0
        public ActionResult Create([Bind(Include = "blog_id,blog_article,blogger_name,blogger_email,blogger_image,blog_image")] blog blog)
        {
            if (ModelState.IsValid)
            {
                db.blogs.Add(blog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(blog));
        }
示例#20
0
        public ActionResult blogGüncelle(blog b)
        {
            var blg = c.blogs.Find(b.ID);

            blg.Aciklama  = b.Aciklama;
            blg.Baslik    = b.Baslik;
            blg.BlogImage = b.BlogImage;
            blg.Tarih     = b.Tarih;
            c.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,orderdate,duedate,status,comment,tags,userID,daordered,wordcount,anchortext,targeturl,posttitle,postplacement,da")] blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.userID = new SelectList(db.users, "ID", "firstname", blog.userID);
     return(View(blog));
 }
 public ActionResult Edit2([Bind(Include = "id,title,photo,date,category_id,dec,text")] blog blog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.category_id = new SelectList(db.blog_category, "id", "name", blog.category_id);
     return(View(blog));
 }
示例#23
0
        public ActionResult Create([Bind(Include = "BlogID,Name")] blog blog)
        {
            if (ModelState.IsValid)
            {
                db.blogs.Add(blog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(blog));
        }
示例#24
0
        public IHttpActionResult Postblog(blog blog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.blog_insert(blog.UserId, blog.BlogTitle, blog.BlogImage, blog.BlogContent, blog.Blogtype);
            //db.blogs.Add(blog);
            //db.SaveChanges();
            return(CreatedAtRoute("DefaultApi", new { id = blog.UserId }, blog));
        }
示例#25
0
        public ActionResult Edit([Bind(Include = "ID,daordered,wordcount,anchortext,targeturl,posttitle,postplacement,da,orderID")] blog blog)
        {
            int orderid = blog.orderID;

            if (ModelState.IsValid)
            {
                db.Entry(blog).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details", "orders", new { @id = orderid }));
            }
            ViewBag.orderID = new SelectList(db.orders, "ID", "orderno", blog.orderID);
            return(View(blog));
        }
示例#26
0
        public ActionResult updatedetails(int id)
        {
            blog blog = db.blogs.Find(id);

            if (User.IsInRole("Admin"))
            {
                return(PartialView("_adminupdatedetails", blog));
            }
            else
            {
                return(PartialView("_userupdatedetails", blog));
            }
        }
        public ActionResult Delete(blog _deletePostItem)
        {
            try
            {
                var deletePostItem = _repo.Delete(_deletePostItem);

                return RedirectToAction("Index/" + "#PostHasBeenDeleted");
            }
            catch(Exception e)
            {
                throw e;
            }
        }
        public ActionResult Create(blog _objCreateItems)
        {
            try
            {
                var createNewPost = _repo.Add(_objCreateItems);

                return RedirectToAction("Index/" + "#PostHasBeenAdded");
            }
            catch(Exception e)
            {
                throw e;
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            blog   blog     = db.blogs.Find(id);
            string fullPath = Request.MapPath("~/Uploads/" + blog.photo);

            if (System.IO.File.Exists(fullPath))
            {
                System.IO.File.Delete(fullPath);
            }
            db.blogs.Remove(blog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: blogsCrud/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            blog blog = db.blogs.Find(id);

            if (blog == null)
            {
                return(HttpNotFound());
            }
            return(View(blog));
        }
示例#31
0
        //插入文章数据
        public void insertBlog(int _userId, int _typeId, string _blogTitle, string _blogContent, DateTime _dateTime)
        {
            blog blogItem = new blog
            {
                userId      = _userId,
                typeId      = _typeId,
                blogTitle   = _blogTitle,
                blogContent = _blogContent,
                blogTime    = _dateTime
            };

            db.blog.InsertOnSubmit(blogItem);
            db.SubmitChanges();
        }
        // GET: SIngleBlog
        public ActionResult Index(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            dynamic mymodel = new ExpandoObject();
            blog    blg     = db.blogs.Find(id);

            mymodel.myblog     = db.blogs.ToList();
            mymodel.Blog       = blg;
            mymodel.otherblogs = db.blogs.Where(o => o.id != id && o.category_id == blg.category_id).Take(3).ToList();
            return(View(mymodel));
        }
        public ActionResult Edit(blog _blogItems)
        {
            try
            {
                var postBlogItems = _repo.Edit(_blogItems);

                return RedirectToAction("Index/" + "#PostHasBeenEdited");
            }
            catch(Exception e)
            {
                throw e;
            }
        }