コード例 #1
0
ファイル: BlogController.cs プロジェクト: nikoladoncev/test
 public ActionResult EditingAddNewPartial([ModelBinder(typeof(DevExpress.Web.Mvc.DevExpressEditorsBinder))] Model.BlogGrupa BlogGrupa)
 {
     Model.BazaEntities  db = new Model.BazaEntities ();
     try
     {
         Model.BlogGrupa newBlogGrupa = new Model.BlogGrupa();
         newBlogGrupa.BlogGrupaNaziv = BlogGrupa.BlogGrupaNaziv;
         db.AddToBlogGrupas(newBlogGrupa);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         ViewData["EditError"] = e.Message;
     }
     return PartialView("BlogPartial", (from r in db.BlogGrupas select r).ToList());
 }
コード例 #2
0
ファイル: Blog.cs プロジェクト: nikoladoncev/test
 public static String EditBLog(string _BlogNaslov, string _BlogSodrzina, int _blogGtupaID,int _blogID)
 {
     string _ret = "0";
     Model.BazaEntities db = new Model.BazaEntities();
     try
     {
         Model.Blog editBlog = db.Blogs.First(i => i.BlogID == _blogID);
         editBlog.BlogNaslov = _BlogNaslov;
         editBlog.BlogSodrzina = _BlogSodrzina;
         editBlog.BlogGrupaID = _blogGtupaID;
         editBlog.BlogVreme = DateTime.Now;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         _ret = e.Message;
     }
     return _ret;
 }
コード例 #3
0
ファイル: BlogController.cs プロジェクト: nikoladoncev/test
        public ActionResult EditingDeletePartial(int BlogGrupaID)
        {
            Model.BazaEntities  db = new Model.BazaEntities ();
            if (BlogGrupaID >= 0)
            {
                try
                {

                    Model.BlogGrupa deleteBlogGrupa = db.BlogGrupas.First(i => i.BlogGrupaID == BlogGrupaID);
                    if (deleteBlogGrupa != null)
                        db.BlogGrupas.DeleteObject(deleteBlogGrupa);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            return PartialView("BlogPartial", (from r in db.BlogGrupas select r).ToList());
        }
コード例 #4
0
ファイル: Blog.cs プロジェクト: nikoladoncev/test
 public static IEnumerable GetBlogGrupas()
 {
     Model.BazaEntities db = new Model.BazaEntities();
     return (from r in db.BlogGrupas select r).ToList();
 }
コード例 #5
0
ファイル: Blog.cs プロジェクト: nikoladoncev/test
 public static String InsertBLog(string _BlogNaslov, string _BlogSodrzina, int _blogGtupaID)
 {
     string _ret="0";
     MembershipUser myObject = Membership.GetUser();
     Guid UserID = (Guid)myObject.ProviderUserKey;
     Model.BazaEntities db = new Model.BazaEntities();
     try
     {
         Model.Blog newBlog = new Model.Blog();
         newBlog.BlogNaslov = _BlogNaslov;
         newBlog.BlogSodrzina = _BlogSodrzina;
         newBlog.BlogGrupaID = _blogGtupaID;
         newBlog.BlogBrojGlasovi = 0;
         newBlog.BlogBrojKomentar  = 0;
         newBlog.BlogBrojPregledi = 0;
         newBlog.BlogVreme  = DateTime.Now;
         newBlog.UserID  = UserID;
         db.AddToBlogs(newBlog);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         _ret = e.Message;
     }
     return _ret;
 }
コード例 #6
0
ファイル: Blog.cs プロジェクト: nikoladoncev/test
 public static IEnumerable GetMyBlogs()
 {
     Model.BazaEntities db = new Model.BazaEntities();
     MembershipUser myObject = Membership.GetUser();
     Guid UserID =  (Guid)myObject.ProviderUserKey;
     return (from r in db.Blogs
             join au in db.aspnet_Users on r.UserID equals au.UserId
             join Kategorija in db.BlogGrupas on r.BlogGrupaID equals Kategorija.BlogGrupaID
             where r.UserID == UserID
             orderby r.BlogVreme descending
             select new BlogView
             {
                 BlogID = r.BlogID,
                 BlogNaslov = r.BlogNaslov,
                 BlogSodrzina = r.BlogSodrzina,
                 BlogVreme = r.BlogVreme,
                 UserID = r.UserID,
                 BlogBrojKomentar = r.BlogBrojKomentar,
                 BlogBrojGlasovi = r.BlogBrojGlasovi,
                 BlogBrojPregledi = r.BlogBrojPregledi,
                 BlogGrupaID = r.BlogGrupaID,
                 UserName = au.UserName,
                 BlogGrupaNaziv = Kategorija.BlogGrupaNaziv
             }).ToList();
 }
コード例 #7
0
ファイル: Blog.cs プロジェクト: nikoladoncev/test
 public static IEnumerable GetBlogs()
 {
     Model.BazaEntities  db = new Model.BazaEntities();
     return (from r in db.Blogs
             join au in db.aspnet_Users on r.UserID equals au.UserId
             join Kategorija in db.BlogGrupas on r.BlogGrupaID equals Kategorija.BlogGrupaID
             orderby r.BlogVreme descending
             select new BlogView
             {
                 BlogID = r.BlogID,
                 BlogNaslov = r.BlogNaslov,
                 BlogSodrzina = r.BlogSodrzina,
                 BlogVreme = r.BlogVreme,
                 UserID = r.UserID,
                 BlogBrojKomentar = r.BlogBrojKomentar,
                 BlogBrojGlasovi =r .BlogBrojGlasovi,
                 BlogBrojPregledi = r.BlogBrojPregledi,
                 BlogGrupaID = r.BlogGrupaID ,
                 UserName = au.UserName,
                 BlogGrupaNaziv = Kategorija.BlogGrupaNaziv
                 }).ToList();
 }
コード例 #8
0
ファイル: BlogController.cs プロジェクト: nikoladoncev/test
 public ActionResult BlogPartial()
 {
     Model.BazaEntities  db = new Model.BazaEntities ();
     return PartialView((from r in db.BlogGrupas select r).ToList());
 }
コード例 #9
0
ファイル: BlogController.cs プロジェクト: nikoladoncev/test
 public ActionResult MyBlogs()
 {
     if (Session["MyBlogPages"] == null)
         Session["MyBlogPages"] = 0;
     int RedBr = Convert.ToInt32(Session["MyBlogPages"].ToString());
     Model.BazaEntities db = new Model.BazaEntities();
     return View((from r in db.BlogGrupas select r).OrderBy(r => r.BlogGrupaNaziv).Skip(RedBr).Take(20).ToList());
 }
コード例 #10
0
ファイル: BlogController.cs プロジェクト: nikoladoncev/test
 public ActionResult EditingUpdatePartial([ModelBinder(typeof(DevExpress.Web.Mvc.DevExpressEditorsBinder))] Model.BlogGrupa BlogGrupa)
 {
     Model.BazaEntities  db = new Model.BazaEntities ();
     try
     {
         Model.BlogGrupa editBlogGrupa = db.BlogGrupas.First(i => i.BlogGrupaID == BlogGrupa.BlogGrupaID);
         editBlogGrupa.BlogGrupaNaziv = BlogGrupa.BlogGrupaNaziv;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         ViewData["EditError"] = e.Message;
     }
     return PartialView("BlogPartial", (from r in db.BlogGrupas select r).ToList());
 }