Ejemplo n.º 1
0
        public ActionResult Login(LoginVM model)
        {
            if (ModelState.IsValid)
            {
                using (ContentSharingEntities1 db = new ContentSharingEntities1())
                {
                    bool control = db.UserTable.Any(x => x.EmailAddress == model.EmailAddress && x.Password == model.Password && x.IsEnabled == true);

                    if (control == true)
                    {
                        //oturum aç
                        FormsAuthentication.SetAuthCookie(model.EmailAddress, true);

                        return(Redirect("/Account/Hot"));
                    }
                }

                JsonMessageResult j = new JsonMessageResult();
                j.IsSuccess   = true;
                j.Message     = "Kullanıcı adı veya parola hatalı!";
                j.RedirectUrl = "/Home/Main";

                return(Json(j));
            }


            return(Json("Böyle bir Kullanıcı veya parola bulunamadı!"));
        }
Ejemplo n.º 2
0
        public ActionResult Trending()
        {
            ContentSharingEntities1 db = new ContentSharingEntities1();


            var model2 = db.ImgDB.ToList();


            List <ImageDBList> model = new List <ImageDBList>(model2.Count);

            for (int i = 0; i < model2.Count; i++)
            {
                ImageDBList List = new ImageDBList()
                {
                    ImgID         = model2[i].ImgID,
                    UserID        = model2[i].UserID,
                    Route         = model2[i].Route,
                    Description   = model2[i].Description,
                    CommentNumber = model2[i].Comment.Count(),
                    VoteNumber    = model2[i].ImgVote.Count
                };

                if (List.VoteNumber > 5)
                {
                    model.Add(List);
                }
            }



            return(View(model));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
        public ActionResult Settings()
        {
            using (ContentSharingEntities1 DB = new ContentSharingEntities1())
            {
                var user = DB.UserTable.FirstOrDefault(x => x.EmailAddress == HttpContext.User.Identity.Name);

                ViewBag.EmailAdress = user.EmailAddress;
                ViewBag.UserName    = user.UserName;
            }

            return(View());
        }
Ejemplo n.º 7
0
        public ActionResult ResetPassword(string code)
        {
            ContentSharingEntities1 db = new ContentSharingEntities1();
            var usr = db.UserTable.FirstOrDefault(x => x.ActivationCode == code);

            if (usr != null)
            {
                ViewBag.Code = usr.ActivationCode;
                return(View());
            }

            return(Redirect("/account/login"));
        }
Ejemplo n.º 8
0
        // GET: Account
        public ActionResult Upload()
        {
            if (HttpContext.User.Identity.IsAuthenticated)
            {
                //cookie deki bilgiyi name ile çektik
                ViewBag.Email = HttpContext.User.Identity.Name;
            }

            ContentSharingEntities1 ImgDB = new ContentSharingEntities1();
            var model = ImgDB.ImgDB.ToList();

            return(View(model));
        }
Ejemplo n.º 9
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"));
        }
Ejemplo n.º 10
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"));
            }
        }
Ejemplo n.º 11
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"));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
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());
        }
Ejemplo n.º 14
0
        public ActionResult PasswordReset(string Email)
        {
            ContentSharingEntities1 db = new ContentSharingEntities1();
            var usr = db.UserTable.FirstOrDefault(x => x.EmailAddress == Email && x.IsEnabled == true);

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

            MailTemplate t = new MailTemplate();

            t.To      = Email;
            t.Message = "<a href=" + url + ">Parola Resetle</a>";
            t.Subject = "Parola Değişikliği";

            MailService service = new MailService();

            service.SendMessage(t);

            ViewBag.Message = "Lütfen eposta hesabınızı kontrol ediniz";

            return(View());
        }
Ejemplo n.º 15
0
        public ActionResult Comment(string id)
        {
            int newid = Convert.ToInt32(id);

            ContentSharingEntities1 DB = new ContentSharingEntities1();

            List <Comments> Comment = new List <Comments>();


            var data = (from d in DB.ImgDB where d.ImgID == newid select d).First();

            ViewBag.ID          = data.ImgID;
            ViewBag.Route       = data.Route;
            ViewBag.Description = data.Description;
            ViewBag.Point       = data.ImgVote.Count;
            ViewBag.Comment     = data.Comment.Count;



            var model = (from a in DB.Comment where a.ImageID == newid select a).ToList();

            for (int i = 0; i < model.Count; i++)
            {
                Comments CList = new Comments()
                {
                    CommentText  = model[i].CommentText,
                    VoteComment  = model[i].VoteComment,
                    ImgID        = model[i].ImageID,
                    CommentUsrID = model[i].UserID,
                    UserName     = model[i].UserTable.UserName
                };

                Comment.Add(CList);
            }



            return(View(Comment));
        }
Ejemplo n.º 16
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());
        }
Ejemplo n.º 17
0
        public ActionResult Hot()
        {
            ContentSharingEntities1 db = new ContentSharingEntities1();


            var model2 = db.ImgDB.ToList();


            List <ImageDBList> model = new List <ImageDBList>(model2.Count);

            for (int i = 0; i < model2.Count; i++)
            {
                ImageDBList List = new ImageDBList()
                {
                    ImgID         = model2[i].ImgID,
                    UserID        = model2[i].UserID,
                    Route         = model2[i].Route,
                    Description   = model2[i].Description,
                    CommentNumber = model2[i].Comment.Count(),
                    VoteNumber    = model2[i].ImgVote.Count
                };

                if (List.VoteNumber > 7)
                {
                    model.Add(List);
                }
            }



            return(View(model));



            //var model2 = (from I in db.ImgDB
            //              join C in db.Comment
            //              on I.ImgID equals C.ImageID
            //              into groupofleft
            //              group I by I.ImgID into grup
            //              select new
            //              {
            //                  ImgID = grup.Key,
            //                  Count = grup.Count()
            //              }).ToList();


            //var model3 = (from I in db.ImgDB
            //              join C in db.Comment on I.ImgID equals C.ImageID into j1
            //              from j2 in j1.DefaultIfEmpty()
            //              group j2 by
            //              new
            //              {
            //                  I.ImgID,
            //                  I.Route,
            //                  I.UserID,
            //                  I.Description
            //              }
            //              into grouped
            //              select new
            //              {
            //                  ParentId = grouped.Key,
            //                  Count = grouped.Count(x => x.ImageID != null)


            //              }).ToList();

            //var model4 = (from C in db.Comment
            //              join I in db.ImgDB on C.ImageID equals I.ImgID into j1
            //              from j2 in j1.DefaultIfEmpty()
            //              group j2 by C.ImageID into grouped
            //              select new
            //              {

            //                  ParentId = grouped.Key,
            //                  Route = grouped.Select(x=> x.Route),
            //                  Count = grouped.Count(x => x.ImgID != null)


            //              }).ToList();


            //var model = from I in db.ImgDB group I by I.ImgID;

            //var model = sql("Select ImgDB.ImgID,ImgDB.ImgVote,ImgDB.Route,ImgDB.UserID,ImgDB.Description,Count(Comment.ImageID) as Sum_Comment from ImgDB left JOIN Comment on(ImgDB.ImgID = Comment.ImageID) group by ImgDB.ImgID,ImgDB.ImgVote,ImgDB.Route,ImgDB.UserID,ImgDB.Description").ToList();
        }