Пример #1
0
        public ActionResult AddArticle(article art, HttpPostedFileBase IMAGE)
        {
            Image img = Image.FromStream(IMAGE.InputStream);

            Bitmap sIamge = new Bitmap(img, Settings.smallImage);
            Bitmap mImage = new Bitmap(img, Settings.mediumImage);
            Bitmap bImage = new Bitmap(img, Settings.bigImage);

            sIamge.Save(Server.MapPath("/Content/images/article_image/small/" + IMAGE.FileName));
            mImage.Save(Server.MapPath("/Content/images/article_image/medium/" + IMAGE.FileName));
            bImage.Save(Server.MapPath("/Content/images/article_image/big/" + IMAGE.FileName));

            article_image a_image = new article_image();

            a_image.BIG  = "/Content/images/article_image/big/" + IMAGE.FileName;
            a_image.MED  = "/Content/images/article_image/medium/" + IMAGE.FileName;
            a_image.MINI = "/Content/images/article_image/small/" + IMAGE.FileName;

            bdg.article_image.Add(a_image);
            bdg.SaveChanges();

            art.IMAGEID = a_image.IMAGEID;
            art.ADATE   = DateTime.Now;
            art.AVIEW   = 0;
            art.ALIKE   = 0;
            int writerId = bdg.users.FirstOrDefault(x => x.USERNAME == User.Identity.Name).USERID;

            art.WRITERID = writerId;
            bdg.articles.Add(art);
            bdg.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Пример #2
0
        public ActionResult SignUp(user u)
        {
            var userControl = bdg.users.Any(x => x.USERNAME == u.USERNAME || x.USEREMAIL == u.USEREMAIL);

            if (userControl)
            {
                ModelState.AddModelError("Error", "Email veya kullanıcı adı alınmış");
                return(View());
            }
            else
            {
                u.WRITER             = false;
                u.APPROVED           = true;
                u.ACTIVE             = true;
                u.DATEOFREGISTRATION = DateTime.Now;
                bdg.users.Add(u);
                bdg.SaveChanges();


                role member = bdg.roles.FirstOrDefault(x => x.ROLENAME == "Üye");

                user_role ur = new user_role();
                ur.ROLEID = member.ROLEID;
                ur.USERID = u.USERID;

                bdg.user_role.Add(ur);
                bdg.SaveChanges();
                return(RedirectToAction("Login"));
            }
        }
Пример #3
0
        public ActionResult wRole(int id)
        {
            user u = bdg.users.FirstOrDefault(x => x.USERID == id);

            u.APPROVED = true;

            user_role ur = new user_role();

            ur = bdg.user_role.FirstOrDefault(x => x.USERID == id);
            bdg.user_role.Remove(ur);
            bdg.SaveChanges();

            role writer = bdg.roles.FirstOrDefault(x => x.ROLENAME == "Yazar");

            ur.ROLEID = writer.ROLEID;
            ur.USERID = id;

            bdg.user_role.Add(ur);
            bdg.SaveChanges();

            return(RedirectToAction("wApproved"));
        }
Пример #4
0
        public ActionResult WriterON(string bio)
        {
            int userId = bdg.users.FirstOrDefault(x => x.USERNAME == User.Identity.Name).USERID;
            var u      = bdg.users.Find(userId);

            u.WRITER          = true;
            u.APPROVED        = false;
            u.BIO             = bio;
            Session["WRITER"] = u.WRITER;
            bdg.SaveChanges();



            return(RedirectToAction("Index", "Home"));
        }