Esempio n. 1
0
        public JsonResult DownVote(string id)
        {
            var newid = Int32.Parse(id);



            ContentSharingEntities1 DB = new ContentSharingEntities1();


            var userid = (from a in DB.UserTable where a.EmailAddress == HttpContext.User.Identity.Name select a.Id).First();


            bool exist = (from b in DB.ImgVote where b.UserID == userid && b.ImgID == newid select b).Any();

            if (exist)
            {
                var imgid = (from c in DB.ImgVote where c.UserID == userid && c.ImgID == newid select c.ImgVoteID).First();


                int newID = Convert.ToInt32(imgid);

                ImgVote Img = DB.ImgVote.Find(newID);

                DB.ImgVote.Remove(Img);
                DB.SaveChanges();

                return(Json("1", JsonRequestBehavior.AllowGet));
            }


            return(Json("0", JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult UpVote(string id)
        {
            var newid = Int32.Parse(id);



            ContentSharingEntities1 DB = new ContentSharingEntities1();

            ImgVote Img = new ImgVote();

            var userid = (from a in DB.UserTable where a.EmailAddress == HttpContext.User.Identity.Name select a.Id).First();

            bool exist = (from b in DB.ImgVote where b.UserID == userid && b.ImgID == newid select b).Any();

            if (!exist)
            {
                Img.ImgID  = newid;
                Img.UserID = userid;

                DB.ImgVote.Add(Img);
                DB.SaveChanges();

                return(Json("1", JsonRequestBehavior.AllowGet));
            }


            return(Json("0", JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public ActionResult Register(RegisterVM model)
        {
            if (ModelState.IsValid)
            {
                UserTable t = new UserTable();

                t.EmailAddress   = model.EmailAddress;
                t.UserName       = model.UserName;
                t.Password       = model.Password;
                t.IsEnabled      = false;
                t.ActivationCode = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);



                using (ContentSharingEntities1 db = new ContentSharingEntities1())
                {
                    var a = (from k in db.UserTable where t.EmailAddress == k.EmailAddress select k).Any();

                    if (a == false)
                    {
                        db.UserTable.Add(t);
                        db.SaveChanges();

                        JsonMessageResult j1 = new JsonMessageResult();
                        j1.IsSuccess   = true;
                        j1.Message     = "Kullanıcı Kaydınız Yapıldı.E-Mail Adresinize Doğrulama Linki Gönderildi!";
                        j1.RedirectUrl = "/account/login";

                        var url = Path.Combine("http://localhost:62423/Home/activate/", t.ActivationCode);

                        MailService s = new MailService();
                        s.SendMessage(new MailTemplate {
                            Subject = "Üyelik", To = model.EmailAddress, Message = "<a href=" + url + ">Üyeliği Aktif Et</a>"
                        });

                        return(Json(j1));
                    }
                    else
                    {
                        JsonMessageResult j2 = new JsonMessageResult();
                        j2.IsSuccess   = false;
                        j2.Message     = "Email Adresi zaten mevcut";
                        j2.RedirectUrl = null;

                        return(Json(j2));
                    }
                }
            }

            JsonMessageResult j = new JsonMessageResult();

            j.IsSuccess   = false;
            j.Message     = "Kullanıcı Kaydınız Yapılamadı.Lütfen tekrar Deneyiniz";
            j.RedirectUrl = null;

            return(Json(j));
        }
Esempio n. 4
0
        public ActionResult Upload(HttpPostedFileBase file, string description)
        {
            using (ContentSharingEntities1 DB = new ContentSharingEntities1())
            {
                var ID = (from a in DB.UserTable where a.EmailAddress == HttpContext.User.Identity.Name select a.Id).First();

                var allowedExtensions = new[] { ".jpg", ".gif", ".mp4", ".png" };

                var checkextension = Path.GetExtension(file.FileName).ToLower();

                bool extension = false;

                foreach (var item in allowedExtensions)
                {
                    if (item.Contains(checkextension))
                    {
                        extension = true;
                    }
                }


                if (extension)
                {
                    try
                    {
                        file.SaveAs(Server.MapPath("~/Images/" + file.FileName));
                        string Route = "/Images/" + file.FileName;

                        ImgDB r = new ImgDB();

                        r.UserID      = ID;
                        r.Description = description;
                        r.Route       = Route;


                        ContentSharingEntities1 db = new ContentSharingEntities1();
                        db.ImgDB.Add(r);
                        db.SaveChanges();
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }



            return(Redirect("/Account/Hot"));
        }
Esempio n. 5
0
        public ActionResult Settings(SettingsRe Setting)
        {
            using (ContentSharingEntities1 DB = new ContentSharingEntities1())
            {
                var user = DB.UserTable.FirstOrDefault(x => x.EmailAddress == HttpContext.User.Identity.Name);


                user.UserName     = Setting.UserName;
                user.EmailAddress = Setting.EmailAddress;
                DB.SaveChanges();


                return(Redirect("/Account/Settings"));
            }
        }
Esempio n. 6
0
        public ActionResult Activate(string code)
        {
            using (ContentSharingEntities1 db = new ContentSharingEntities1())
            {
                var user = db.UserTable.FirstOrDefault(x => x.ActivationCode == code);

                if (user != null)
                {
                    user.IsEnabled = true;
                    db.SaveChanges();
                    return(Redirect("/Home/Main"));
                }
            }

            return(Redirect("/Home/Register"));
        }
Esempio n. 7
0
        public ActionResult PostComment(string Comment, int ImageID)
        {
            ContentSharingEntities1 DB = new ContentSharingEntities1();

            var UserID = (from a in DB.UserTable where a.EmailAddress == HttpContext.User.Identity.Name select a.Id).First();

            Comment comment = new Comment();

            comment.CommentText = Comment;
            comment.ImageID     = ImageID;
            comment.UserID      = UserID;
            comment.VoteComment = 0;

            DB.Comment.Add(comment);
            DB.SaveChanges();


            return(Redirect("/Account/Comment?id=" + ImageID));
        }
Esempio n. 8
0
        public ActionResult Password(PasswordRe PW)
        {
            using (ContentSharingEntities1 DB = new ContentSharingEntities1())
            {
                bool Pass = DB.UserTable.Any(x => x.Password == PW.OldPassword);

                var user = DB.UserTable.FirstOrDefault(x => x.EmailAddress == HttpContext.User.Identity.Name);

                //var Pass = (from a in DB.UserTable where a.EmailAddress == HttpContext.User.Identity.Name select a.Password).Single<string>();

                if (Pass)
                {
                    user.Password = PW.NewPassword;
                    DB.SaveChanges();
                }
            }


            return(View());
        }
Esempio n. 9
0
        public ActionResult ResetPassword(PasswordResetVM model)
        {
            var          response = Request["g-recaptcha-response"];
            const string secret   = "6LcjsTQUAAAAALUtX2jw6R8y7oEkK8zHtBolrLli";
            //Kendi Secret keyinizle değiştirin.

            //webclient recaptcha test
            var client = new WebClient();
            var reply  =
                client.DownloadString(
                    string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, response));

            var captchaResponse = JsonConvert.DeserializeObject <CaptchaResponse>(reply);

            if (ModelState.IsValid)
            {
                ContentSharingEntities1 db = new ContentSharingEntities1();
                var usr = db.UserTable.FirstOrDefault(x => x.ActivationCode == model.ActivationCode);

                if (usr != null)
                {
                    if (!captchaResponse.Success)
                    {
                        ViewBag.Message = "Lütfen güvenliği doğrulayınız.";
                    }
                    else
                    {
                        ViewBag.Message = "Güvenlik başarıyla doğrulanmıştır.";
                        usr.Password    = model.Password;
                        db.SaveChanges();
                    }
                }
            }

            return(View());
        }