コード例 #1
0
        public ActionResult Login()
        {
            usersDal adal = new usersDal();

            adal.SaveChanges();
            return(View());
        }
コード例 #2
0
        public void addNewAdmin()
        {
            users    usr;
            usersDal udal = new usersDal();

            List <admins> alist = (from x in adal.adminsLst where x.username.Equals("test") select x).ToList <admins>();

            if (alist.Count == 1)
            {
                adal.adminsLst.RemoveRange(adal.adminsLst.Where(x => x.username.Equals("test")));
                adal.SaveChanges();
            }
            List <users> list = (from x in udal.userLst where x.username.Equals("test") select x).ToList <users>();

            if (list.Count == 0)
            {
                usr = new users {
                    email = "*****@*****.**", firstName = "test", lastName = "test", username = "******", password = "******"
                };
                udal.userLst.Add(usr);
                udal.SaveChanges();
            }


            admins adm = new admins {
                username = "******", aLevel = "A"
            };

            controller.NewAdmin(adm);

            List <admins> listtest = (from x in adal.adminsLst where x.username.Equals("test") select x).ToList <admins>();

            Assert.AreEqual(listtest.Count, 1);
        }
コード例 #3
0
        public ActionResult editProfile()
        {
            string  firstname    = Request.Form["firstName"].ToString();
            string  lastname     = Request.Form["lastName"].ToString();
            string  bio          = Request.Form["biography"].ToString();
            string  pass         = Request.Form["password"].ToString();
            string  repass       = Request.Form["repassword"].ToString();
            Profile oldDBProfile = GetProfile();
            users   oldDBUser    = GetUser();

            oldDBUser.firstName    = firstname;
            oldDBUser.lastName     = lastname;
            oldDBProfile.biography = bio;
            if (pass != "" && pass == repass)
            {
                oldDBUser.password = pass;
            }
            else if (pass != "" && pass != repass)
            {
                TempData["ERROR"] = "Unmatched Passwords! , try again.";
            }

            usersDal   udal = new usersDal();
            profileDal pdal = new profileDal();

            udal.userLst.RemoveRange(udal.userLst.Where(x => x.username == oldDBUser.username));
            udal.SaveChanges();
            udal.userLst.Add(oldDBUser);
            udal.SaveChanges();
            pdal.profilesList.RemoveRange(pdal.profilesList.Where(x => x.username == oldDBProfile.username));
            pdal.SaveChanges();
            pdal.profilesList.Add(oldDBProfile);
            pdal.SaveChanges();
            return(RedirectToAction("MyProfile", "User"));
        }
コード例 #4
0
        public void delete_test_user()
        {
            usersDal     udal       = new usersDal();
            List <users> check_user = (from x in udal.userLst where x.username.Equals("test") select x).ToList <users>();

            if (check_user.Count == 1)
            {
                udal.userLst.RemoveRange(udal.userLst.Where(x => x.username.Equals("test")));
                udal.SaveChanges();
            }
        }
コード例 #5
0
        public users GetUser()
        {
            usersDal     dal         = new usersDal();
            string       currentuser = Session["CurrentUsername"].ToString();
            List <users> curr        = (from x in dal.userLst
                                        where x.username == currentuser
                                        select x).ToList <users>();

            user = curr[0];
            return(curr[0]);
        }
コード例 #6
0
        public ActionResult RegAction(users userReg)
        {
            usersDal       emails   = new usersDal();
            profileDal     pdal     = new profileDal();
            UsersStatusDal usdal    = new UsersStatusDal();
            List <users>   checkLSt = (from tmp in emails.userLst where tmp.email.Contains(userReg.email) select tmp).ToList <users>();

            if (checkLSt.Count > 0)
            {
                ViewData["eMess"] = "This e-mail has registered before\n try another one.";
            }
            else
            {
                if (userReg.password != Request.Form["rePass"])
                {
                    ViewData["pMess"] = "The passwords doesn't match";
                }
                else if (userReg.password.Length < 6)
                {
                    ViewData["pMess"] = "The password length must be greater than 6";
                }
                else
                {
                    Profile        profile    = new Profile();
                    usersStatus    uss        = new usersStatus();
                    List <Profile> defProfile = (from x in pdal.profilesList
                                                 where x.username.Equals("testImage")
                                                 select x).ToList <Profile>();
                    emails.userLst.Add(userReg);
                    emails.SaveChanges();
                    profile.username  = userReg.username;
                    profile.biography = "empty";
                    profile.image     = defProfile[0].image;
                    pdal.profilesList.Add(profile);
                    uss.username = userReg.username;
                    uss.status   = "Activated";
                    usdal.statuses.Add(uss);
                    usdal.SaveChanges();

                    try
                    {
                        pdal.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    return(View("Login"));
                }
            }
            return(View("Register"));
        }
コード例 #7
0
        public void  new_user_Register()
        {
            users usr = new users {
                email = "*****@*****.**", firstName = "test", lastName = "test", username = "******", password = "******"
            };
            usersDal udal = new usersDal();

            udal.userLst.RemoveRange(udal.userLst.Where(x => x.username.Equals(usr.username)));
            udal.userLst.Add(usr);
            udal.SaveChanges();
            List <users> database = (from x in udal.userLst where x.username == usr.username select x).ToList <users>();

            Assert.AreEqual(database.Count, 1);
        }
コード例 #8
0
        public ActionResult RedirectToProfile()
        {
            string         usr     = Request.Form["usr"].ToString();
            usersDal       uDal    = new usersDal();
            UserViewModel  view    = new UserViewModel();
            profileDal     pDal    = new profileDal();
            List <Profile> profile = (from x in pDal.profilesList
                                      where x.username.Equals(usr)
                                      select x).ToList <Profile>();
            List <users> u = (from x in uDal.userLst
                              where x.username.Equals(usr)
                              select x).ToList <users>();

            view.profile = profile[0];
            view.user    = u[0];
            return(View(view));
            //return RedirectToAction("ViewFriendProfile", "Profile", usrname);
        }
コード例 #9
0
        public void get_users_information()
        {
            usersDal udal = new usersDal();
            users    usr;

            delete_test_user();
            List <users> list         = (from x in udal.userLst select x).ToList <users>();
            int          users_number = list.Count;


            //Add a new user.
            usr = new users {
                email = "*****@*****.**", firstName = "test", lastName = "test", username = "******", password = "******"
            };
            udal.userLst.Add(usr);
            udal.SaveChanges();

            list = (from x in udal.userLst select x).ToList <users>();

            //Check if gett all users correctly!
            Assert.AreEqual(users_number + 1, list.Count);
        }
コード例 #10
0
    //用户登录
    protected void UserLogin(string name, string pwd)
    {
        usersDal  md  = new usersDal();
        DataTable dt1 = md.inquiry_login(name);

        if (dt1.Rows.Count <= 0)
        {
            Response.Redirect("fail");
            return;
        }

        if (dt1.Rows[0][0].ToString() == pwd)
        {
            Session["user"]   = dt1.Rows[0][1].ToString();
            Session["userid"] = name;
            Response.Write("success");
        }
        else
        {
            Response.Redirect("fail");
        }
    }
コード例 #11
0
        public ActionResult LogAction(users info)
        {
            usersDal       usrInfo = new usersDal();
            adminsDal      admin   = new adminsDal();
            UsersStatusDal usdal   = new UsersStatusDal();
            List <users>   user    = (from usr in usrInfo.userLst
                                      where usr.username.Equals(info.username) &&
                                      usr.password.Equals(info.password)
                                      select usr).ToList <users>();
            List <admins> adminsLst = (from x in admin.adminsLst
                                       where x.username.Equals(info.username)
                                       select x).ToList <admins>();
            List <usersStatus> statuslist = (from x in usdal.statuses
                                             where x.username.Equals(info.username)
                                             select x).ToList <usersStatus>();

            Session["Admin"] = "False";
            if (adminsLst.Count() == 1)
            {
                Session["admin"] = "True";
            }
            if (user.Count() == 1)
            {
                if (statuslist[0].status.Equals("Deactivated"))
                {
                    TempData["LogMess"] = "your account deactivated by admins!";
                    return(View("Login"));
                }
                Session["CurrentUsername"] = info.username;
                Session["firstName"]       = user[0].firstName;
                Session["lastName"]        = user[0].lastName;
                Session["connected"]       = "1";
                return(RedirectToAction("UserMainPage", "User"));
            }
            TempData["LogMess"] = "The username or the password isn't correct";
            return(View("Login"));
        }
コード例 #12
0
    //获取在线用户
    protected void GetOnline()
    {
        usersDal  ud1 = new usersDal();
        DataTable dt2 = ud1.inquiry_users();

        if (dt2.Rows.Count <= 0)
        {
            Response.Write("fail");
        }
        else
        {
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                string inid   = Convert.ToString(dt2.Rows[i]["UserID"]);
                string inname = Convert.ToString(dt2.Rows[i]["NickName"]);
                if (Convert.ToInt32(Session["userid"]) == Convert.ToInt32(inid))
                {
                    inid   = "";
                    inname = "张家港时间众筹会所";
                }
                Response.Write("<li id='" + inid + "'>" + inname + "</li>");
            }
        }
    }
コード例 #13
0
        public JsonResult CheckLogInInformation(string username1)
        {
            usersDal      db  = new usersDal();
            userMomentDal umd = new userMomentDal();

            //Momentmaxnumber

            string getmax = Session["getthemaxnumber"].ToString();
            int    value  = Convert.ToInt32(getmax);



            int getmidnumber = Convert.ToInt32(Session["getmidd"]);

            System.Threading.Thread.Sleep(2000);
            var GetIfUserExist = db.userLst.Where(x => x.username == username1).SingleOrDefault();
            List <userMoments> usersingroup = (from tmp in umd.userMomentLST where tmp.mid.Equals(getmidnumber) select tmp).ToList <userMoments>();

            if (usersingroup.Count() <= value)
            {
                if (GetIfUserExist != null)
                {
                    users oh = new users();
                    oh = GetUser();
                    if (username1 != oh.username)
                    {
                        Notifications    n    = new Notifications();
                        notificationsDal nDal = new notificationsDal();
                        int id = (from x in nDal.nLst
                                  select x).ToList <Notifications>().Count() + 1;
                        n.dateSent = DateTime.Now.Date;
                        n.id       = id;
                        n.status   = "Not Accepted";
                        n.type     = "invite " + Session["mid"];
                        n.username = username1;
                        n.uFrom    = oh.username;
                        nDal.nLst.Add(n);
                        nDal.SaveChanges();

                        /*
                         * userMoments usermoment = new userMoments();
                         * usermoment.id = 1;
                         * usermoment.mid = Convert.ToInt32(Session["mid"]);
                         * usermoment.GroupName = Session["MomentName1"].ToString();
                         * usermoment.username = username1;
                         * usermoment.uType = "User";
                         * umd.userMomentLST.Add(usermoment);
                         * umd.SaveChanges();
                         */
                        return(Json(1));
                    }
                    else
                    {
                        return(Json(2));
                    }
                }
                else
                {
                    return(Json(0));
                }
            }
            else
            {
                return(Json(3));
            }
        }