示例#1
0
 public ActionResult Edit(user user)
 {
     if (ModelState.IsValid)
     {
         Db.Entry(user).State = EntityState.Modified;
         Db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TypeId = new SelectList(Db.usertype, "Id", "Name", user.TypeId);
     return(View(user));
 }
 public ActionResult Create(category category)
 {
     if (ModelState.IsValid)
     {
         category.Seo = OK.ConvertSeo(category.Name);
         Db.category.Add(category);
         Db.SaveChanges();
         return(RedirectToAction("index"));
     }
     return(View(category));
 }
示例#3
0
        public ActionResult Create(menulink menulink)
        {
            if (ModelState.IsValid)
            {
                Db.menulink.Add(menulink);
                Db.SaveChanges();
                return(RedirectToAction("index"));
            }

            return(View(menulink));
        }
 public ActionResult Create(notice notice)
 {
     if (ModelState.IsValid)
     {
         notice.CreationDate = DateTime.Now;
         Db.notice.Add(notice);
         Db.SaveChanges();
         return(RedirectToAction("index"));
     }
     return(View(notice));
 }
示例#5
0
        public ActionResult Create(config config)
        {
            if (ModelState.IsValid)
            {
                Db.config.Add(config);
                Db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(config));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "ID,Title,Content,OwnerID,CreationDate,IsApproval")] Widget widget)
        {
            if (ModelState.IsValid)
            {
                db.Widgets.Add(widget);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OwnerID = new SelectList(db.Users, "ID", "Email", widget.OwnerID);
            return(View(widget));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Description,ShortURL,ParentID,SectionID,Sort,IsApproval")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SectionID = new SelectList(db.Sections, "ID", "Name", category.SectionID);
            return(View(category));
        }
示例#8
0
        public ActionResult Create([Bind(Include = "ID,Name,Address,Target,IsApproval,Sort,PageID")] Link link)
        {
            if (ModelState.IsValid)
            {
                db.Links.Add(link);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PageID = new SelectList(db.Pages, "ID", "Name", link.PageID);
            return(View(link));
        }
示例#9
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,ShortURL,PageID,Sort,IsApproval,SectionTemplate,CategoryTemplate,PostTemplate")] Section section)
        {
            if (ModelState.IsValid)
            {
                db.Sections.Add(section);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PageID = new SelectList(db.Pages, "ID", "Name", section.PageID);
            return(View(section));
        }
示例#10
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,ImageURL,OwnerID,ShortURL,ThemeID,CreationDate,IsApproval,IndexTemplate")] Page page)
        {
            if (ModelState.IsValid)
            {
                db.Pages.Add(page);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ThemeID = new SelectList(db.Themes, "ID", "Name", page.ThemeID);
            ViewBag.OwnerID = new SelectList(db.Users, "ID", "Email", page.OwnerID);
            return(View(page));
        }
        public ActionResult Create([Bind(Include = "ID,Content,WritingDate,PostID,WriterID,IsApproval")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PostID   = new SelectList(db.Posts, "ID", "Title", comment.PostID);
            ViewBag.WriterID = new SelectList(db.Users, "ID", "Email", comment.WriterID);
            return(View(comment));
        }
示例#12
0
        public ActionResult Create([Bind(Include = "ID,Title,Content,ShortURL,CreationDate,ModifyDate,IsApproval,CategoryID")] Post post)
        {
            if (ModelState.IsValid)
            {
                db.Posts.Add(post);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.WriterID   = new SelectList(db.Users, "ID", "Email", post.WriterID);
            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", post.CategoryID);
            return(View(post));
        }
示例#13
0
        public ActionResult Create(forum forum)
        {
            if (ModelState.IsValid)
            {
                forum.Seo = OK.ConvertSeo(forum.Name);
                Db.forum.Add(forum);
                Db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(Db.category, "Id", "Name", forum.CategoryId);
            return(View(forum));
        }
示例#14
0
        public ActionResult Create([Bind(Include = "ID,PageID,SectionID,WidgetID,Position,Region,Sort")] PageWidget pageWidget)
        {
            if (ModelState.IsValid)
            {
                db.PageWidgets.Add(pageWidget);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PageID    = new SelectList(db.Pages, "ID", "Name", pageWidget.PageID);
            ViewBag.SectionID = new SelectList(db.Sections, "ID", "Name", pageWidget.SectionID);
            ViewBag.WidgetID  = new SelectList(db.Widgets, "ID", "Title", pageWidget.WidgetID);
            return(View(pageWidget));
        }
示例#15
0
        public static void UpdateRating(int id, int score)
        {
            OKDbEntities Db   = new OKDbEntities();
            var          user = Db.user.Find(id);

            user.Rating += score;
            Db.SaveChanges();
        }
 public ActionResult Create(comment comment)
 {
     if (ModelState.IsValid)
     {
         comment.WriterId     = (int)Session["userid"];
         comment.Rating       = "0/0";
         comment.CreationDate = DateTime.Now;
         comment.ModifyDate   = DateTime.Now;
         Db.comment.Add(comment);
         Db.SaveChanges();
         OK.UpdateRating((int)Session["userid"], +15);
         OK.AddPost((int)comment.WriterId, comment.TopicId.ToString() + "-" + comment.Id.ToString(), "create-comment", (bool)comment.IsApproval);
         return(RedirectToAction("Index"));
     }
     ViewBag.TopicId = new SelectList(Db.topic, "Id", "Title", comment.TopicId);
     return(View(comment));
 }
示例#17
0
 public ActionResult Create(topic topic)
 {
     if (ModelState.IsValid)
     {
         int userid = (int)Session["userid"];
         topic.WriterId     = userid;
         topic.Seo          = OK.ConvertSeo(topic.Title);
         topic.CreationDate = DateTime.Now;
         topic.ModifyDate   = DateTime.Now;
         topic.Rating       = "0/0";
         topic.ViewsCount   = 0;
         Db.topic.Add(topic);
         Db.SaveChanges();
         OK.AddPost(userid, topic.ForumId.ToString() + "-" + topic.Id.ToString(), "create-topic", (bool)topic.IsApproval);
         OK.UpdateRating(userid, +25);
         return(RedirectToAction("index"));
     }
     ViewBag.ForumId = new SelectList(Db.forum, "Id", "Name", topic.ForumId);
     return(View(topic));
 }
示例#18
0
        public static void DeletePost(int userid, string itemid, string type)
        {
            OKDbEntities Db   = new OKDbEntities();
            var          post = Db.post.SingleOrDefault(x => x.UserId == userid && x.ItemId == itemid && x.Type == type);

            if (post != null)
            {
                Db.post.Remove(post);
            }
            Db.SaveChanges();
        }
示例#19
0
        public static void ChangePostApproval(int userid, string itemid, string type, bool isapproval)
        {
            OKDbEntities Db   = new OKDbEntities();
            var          post = Db.post.SingleOrDefault(x => x.UserId == userid && x.ItemId == itemid && x.Type == type);

            if (post != null)
            {
                post.IsApproval = isapproval;
            }
            Db.SaveChanges();
        }
示例#20
0
        public static void AddPost(int userid, string itemid, string type, bool isapproval)
        {
            OKDbEntities Db   = new OKDbEntities();
            post         post = new post();

            post.UserId       = userid;
            post.ItemId       = itemid;
            post.Type         = type;
            post.CreationDate = DateTime.Now;
            post.IsApproval   = isapproval;
            Db.post.Add(post);
            Db.SaveChanges();
        }
示例#21
0
        public ActionResult Login(user model)
        {
            string result;
            string password = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password.ToString(), "md5").ToString();
            var    user     = Db.user.SingleOrDefault(x => x.UserName == model.UserName && x.Password == password);

            if (user == null)
            {
                result = "Böyle bir hesap bulunamadı..";
            }
            else
            {
                if (user.IsBanned == true)
                {
                    result = "<script type=\"text/javascript\">$.OK.ErrorModal('Hesabınızın sitemize girişi yasaklanmıştır..');</script>";
                }
                else if (user.IsApproval == false)
                {
                    result = "<script type=\"text/javascript\">$.OK.ErrorModal('Hesabınız henüz onaylanmamış, daha sonra tekrar deneyiniz..');</script>";
                }
                else
                {
                    Session["userinfo"] = user;
                    Session["userid"]   = user.Id;
                    Session["role"]     = 10; //user.TypeId.ToString();
                    if (model.RememberMe == true)
                    {
                        HttpCookie cookie_username = new HttpCookie("OK_userid");
                        cookie_username.Value   = user.Id.ToString();
                        cookie_username.Expires = DateTime.Now.AddDays(365);
                        HttpCookie cookie_password = new HttpCookie("OK_password");
                        cookie_password.Value   = password;
                        cookie_password.Expires = DateTime.Now.AddDays(365);
                        Response.Cookies.Add(cookie_username);
                        Response.Cookies.Add(cookie_password);
                    }
                    user.LoginCount += 1;
                    Db.SaveChanges();
                    result = "<script type=\"text/javascript\">$.OK.SuccessModal('Hesabınıza giriş yapılıyor..');setTimeout(function () { window.location.href='" + Url.Action("Index", "Forum") + "'; }, 2000);</script>";
                }
            }
            return(Content(result));
        }
示例#22
0
 public ActionResult Membership()
 {
     if (Session["userinfo"] != null)
     {
         int id   = (int)Session["userid"];
         var user = Db.user.Single(x => x.Id == id);
         user.LastLoginDate = DateTime.Now;
         Db.SaveChanges();
         return(PartialView(user));
     }
     else
     {
         return(PartialView());
     }
 }
示例#23
0
        public ActionResult Forum(string seo, int id, int page)
        {
            var forum = Db.forum.SingleOrDefault(x => x.Id == id);

            if (forum != null && forum.IsApproval == true && forum.category.IsApproval == true)
            {
                var parentforum = Db.forum.SingleOrDefault(x => x.Id == forum.ParentForumId);
                if (parentforum != null ? parentforum.IsApproval == true : true)
                {
                    ViewBag.Title    = forum.Name;
                    ViewBag.keywords = forum.Name.Replace(" ", ", ") + ", " + forum.category.Name.Replace(" ", ", ");
                    if (forum.Seo == seo)
                    {
                        int take   = Convert.ToInt32(OK.Config("topic-paging-count"));
                        int skip   = take * (page - 1);
                        var topics = OK.SortTopics(forum.topics);
                        ViewBag.topics      = topics.Where(x => x.IsSticky == true).Concat(topics.Where(x => x.IsSticky == false).Skip(skip).Take(take)).ToList();
                        ViewBag.topiccount  = topics.Where(x => x.IsSticky == false).Count();
                        ViewBag.stickycount = topics.Where(x => x.IsSticky == true).Count();
                        ViewBag.parentforum = parentforum;
                        forum.ViewsCount   += 1;
                        Db.SaveChanges();
                        return(View(forum));
                    }
                    else
                    {
                        return(RedirectToAction("Forum", new { seo = forum.Seo, id = id, page = page }));
                    }
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            else
            {
                return(HttpNotFound());
            }
        }