Exemple #1
0
        public ActionResult EmailConfirmed(ChangePassword chng)
        {
            string password = chng.password;

            if (TempData["id"] != null)
            {
                int          id      = int.Parse(TempData["id"].ToString());
                user         us      = context.users.Find(id);
                passwordHash hash    = new passwordHash();
                string       newpass = hash.CreateMd5(chng.password);
                var          user    = new user {
                    id = id, password = newpass
                };
                using (var db = new socialEntities())
                {
                    db.users.Attach(user);
                    db.Entry(user).Property(x => x.password).IsModified = true;
                    db.SaveChanges();
                }
                TempData["id"] = us.id;
                HttpCookie userId = new HttpCookie("id");
                userId.Value   = us.id.ToString();
                userId.Expires = DateTime.Now.AddHours(2);
                HttpContext.Response.SetCookie(userId);
                Session["User" + us.id] = us;
                return(Redirect("/Profile/Index/"));
            }
            return(View());
        }
Exemple #2
0
        public void  ChangeProfile(int id)
        {
            string   currid = Request.Params["id"].ToString();
            user     us     = Session["User" + currid] as user;
            NewsFeed feed   = db.NewsFeeds.Find(id);
            var      user   = new user {
                id = us.id, profile_photo = feed.photos
            };

            using (var db = new socialEntities())
            {
                db.users.Attach(user);
                db.Entry(user).Property(x => x.profile_photo).IsModified = true;
                try
                {
                    //add to feed
                    NewsFeed feeds = new NewsFeed();
                    feeds.dateTime     = DateTime.Now;
                    feeds.user_id      = us.id;
                    feeds.photos       = feed.photos;
                    feeds.feedState_id = 6;
                    db.NewsFeeds.Add(feeds);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string st = e.Message;
                }
            }
        }
Exemple #3
0
        public async void UnBlock(string id)
        {
            int  iD  = int.Parse(id);
            user usr = await db.users.FindAsync(iD);

            var user = new user {
                id = iD, is_blocked = 0
            };

            using (var db = new socialEntities())
            {
                db.users.Attach(user);
                db.Entry(user).Property(x => x.is_blocked).IsModified = true;
                db.SaveChanges();
            }
        }
Exemple #4
0
        public ActionResult ChangeColor(int id)
        {
            string currid = Request.Params["id"].ToString();
            user   us     = Session["User" + currid] as user;
            string color  = Request.Params["color"].ToString();
            var    user   = new user {
                id = us.id, color = color
            };

            using (var db = new socialEntities())
            {
                db.users.Attach(user);
                db.Entry(user).Property(x => x.color).IsModified = true;
                db.SaveChanges();
            }
            return(Redirect("/Profile/Index/"));
        }
Exemple #5
0
        public JsonResult ChangeExPas()
        {
            int          id      = int.Parse(Request.Params["id"].ToString());
            passwordHash hash    = new passwordHash();
            user         us      = db.users.Find(id);
            string       pasEx   = Request.Params["pasEx"].ToString();
            string       pas     = Request.Params["pas"].ToString();
            string       pasConf = Request.Params["pasConf"].ToString();

            if (pas != pasConf)
            {
                object res = new object();
                res = (new {
                    error = "passwods are not same",
                });
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            else if (hash.CreateMd5(pasEx) != us.password)
            {
                object res = new object();
                res = (new
                {
                    error = "enter correct password",
                });
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var user = new user {
                    id = us.id, password = hash.CreateMd5(pas)
                };
                using (var db = new socialEntities())
                {
                    db.users.Attach(user);
                    db.Entry(user).Property(x => x.password).IsModified = true;
                    db.SaveChanges();
                }
                object res = new object();
                res = (new
                {
                    error = "success",
                });
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #6
0
        public void AddAdv(string id)
        {
            int    advId = int.Parse(id);
            string src   = Request.Params["src"].ToString();
            string cost  = Request.Params["cost"].ToString();
            string url   = Request.Params["url"].ToString();

            url = url.Replace(",/Admin/AddAdv/1", "");
            url = url.Replace(",/Admin/AddAdv/2", "");
            url = url.Replace(",/Admin/AddAdv/3", "");
            List <advert> ads = (from item in db.adverts where item.advNo == advId && item.status == 1 select item).ToList();

            if (ads.Count != 0)
            {
                var adv = new advert {
                    id = ads[0].id, advert1 = src, cost = int.Parse(cost), datetime = DateTime.Now, url = url
                };
                using (var db = new socialEntities())
                {
                    db.adverts.Attach(adv);
                    db.Entry(adv).Property(x => x.advert1).IsModified  = true;
                    db.Entry(adv).Property(x => x.cost).IsModified     = true;
                    db.Entry(adv).Property(x => x.url).IsModified      = true;
                    db.Entry(adv).Property(x => x.datetime).IsModified = true;
                    db.SaveChanges();
                }
            }
            else
            {
                advert ad = new advert();
                ad.advNo    = advId;
                ad.status   = 1;
                ad.advert1  = src;
                ad.url      = url;
                ad.datetime = DateTime.Now;
                ad.cost     = int.Parse(cost);
                db.adverts.Add(ad);
                db.SaveChanges();
            }
        }
Exemple #7
0
        public JsonResult Redact()
        {
            int         id     = int.Parse(Request.Params["id"].ToString());
            user        us     = db.users.Find(id);
            string      name   = Request.Params["name"].ToString();
            string      suname = Request.Params["surname"].ToString();
            int         age    = int.Parse(Request.Params["age"].ToString());
            string      login  = Request.Params["login"].ToString();
            List <user> usrs   = db.users.Where(m => m.login == login).ToList();
            object      res    = new object();

            if (login.Length <= 6 && login != "0")
            {
                res = (new
                {
                    error = "login will contain more than 6 symbol",
                });
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            else if (usrs.Count > 0 && login != "0")
            {
                res = (new
                {
                    error = "login already excist choose another",
                });
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            if (name != "0" || suname != "0" || age.ToString() != "0")
            {
                if (name != "0")
                {
                    var user = new user {
                        id = us.id, name = name
                    };
                    using (var db = new socialEntities())
                    {
                        db.users.Attach(user);
                        db.Entry(user).Property(x => x.name).IsModified = true;
                        db.SaveChanges();
                    }
                }
                if (suname != "0")
                {
                    var user = new user {
                        id = us.id, surname = suname
                    };
                    using (var db = new socialEntities())
                    {
                        db.users.Attach(user);
                        db.Entry(user).Property(x => x.surname).IsModified = true;
                        db.SaveChanges();
                    }
                }
                if (age.ToString() != "0")
                {
                    var user = new user {
                        id = us.id, age = age
                    };
                    using (var db = new socialEntities())
                    {
                        db.users.Attach(user);
                        db.Entry(user).Property(x => x.age).IsModified = true;
                        db.SaveChanges();
                    }
                }
            }
            res = (new
            {
                error = "success",
            });
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
 public ProfileController()
 {
     this.db = new socialEntities();
 }
 public autoNptifSenderController()
 {
     this.context = new socialEntities();
 }
Exemple #10
0
 public ChronoController()
 {
     this.db = new socialEntities();
 }
Exemple #11
0
 public PasswordRecoveryController()
 {
     this.context = new socialEntities();
 }
Exemple #12
0
 public AdminController()
 {
     this.db = new socialEntities();
 }
Exemple #13
0
        public async Task <ActionResult> Index(Log log)
        {
            string       login    = log.login;
            string       password = log.password;
            passwordHash hash     = new passwordHash();
            List <user>  auth     = new List <user>();

            auth = (from item in context.users where item.login == login select item).ToList();
            if (auth.Count == 0 || hash.Validate(password, auth[0].password) == false)
            {
                if (auth[0] != null)
                {
                    int?counter = auth[0].try_count + 1;
                    var user    = new user {
                        id = auth[0].id, try_count = counter
                    };
                    using (var db = new socialEntities())
                    {
                        db.users.Attach(user);
                        db.Entry(user).Property(x => x.try_count).IsModified = true;
                        db.SaveChanges();
                    }
                }
                if (auth[0].block_time < DateTime.Now)
                {
                    if (auth[0] != null)
                    {
                        var user = new user {
                            id = auth[0].id, try_count = 0
                        };
                        using (var db = new socialEntities())
                        {
                            db.users.Attach(user);
                            db.Entry(user).Property(x => x.try_count).IsModified = true;
                            db.SaveChanges();
                        }
                    }
                }
                if (auth[0].is_blocked == 1)
                {
                    auth[0].block_time = DateTime.Now.AddMinutes(30);
                    TimeSpan?time = auth[0].block_time - DateTime.Now;
                    ViewBag.error = string.Format("Administratin block your account");
                    return(View());
                }
                if (auth[0].try_count > 3)
                {
                    auth[0].block_time = DateTime.Now.AddMinutes(30);
                    TimeSpan?time = auth[0].block_time - DateTime.Now;
                    ViewBag.error = string.Format("too many unauthorized attempts your accont has blocked in {0} minutes", time);
                    return(View());
                }
                ViewBag.error = "please enter correct login or password";
                return(View());
            }
            else if (auth[0].ConfirmedEmail == "false")
            {
                ViewBag.error = "we send confirmation message to your Email please confirm it";
                return(View());
            }
            else
            {
                if (auth[0].stat == 1)
                {
                    int iD = auth[0].id;
                    Session["User" + iD.ToString()] = auth[0];
                    HttpCookie userId = new HttpCookie("id");
                    userId.Value   = iD.ToString();
                    userId.Expires = DateTime.Now.AddHours(2);
                    HttpContext.Response.SetCookie(userId);
                    TempData["id"] = iD.ToString();
                    return(RedirectToAction("Index", "Admin"));
                }
                if (auth[0] != null)
                {
                    var user = new user {
                        id = auth[0].id, try_count = 0
                    };
                    using (var db = new socialEntities())
                    {
                        db.users.Attach(user);
                        db.Entry(user).Property(x => x.try_count).IsModified = true;
                        db.SaveChanges();
                    }
                    int iD = auth[0].id;
                    Session["User" + iD.ToString()] = auth[0];
                    HttpCookie userId = new HttpCookie("id");
                    userId.Value   = iD.ToString();
                    userId.Expires = DateTime.Now.AddHours(2);
                    HttpContext.Response.SetCookie(userId);
                    TempData["id"] = iD.ToString();
                    return(RedirectToAction("Index", "Profile"));
                }
                return(View());
            }
        }
Exemple #14
0
 public UserController()
 {
     this.context = new socialEntities();
 }
Exemple #15
0
 public Auto_Notification_SenderController()
 {
     this.db = new socialEntities();
 }
Exemple #16
0
 public FacebookLoginController()
 {
     this.db = new socialEntities();
 }