public ActionResult DeleteUser(string delete)
        {
            profileDal       pdal  = new profileDal();
            UsersStatusDal   usdal = new UsersStatusDal();
            notificationsDal ndal  = new notificationsDal();
            friendsDal       fdal  = new friendsDal();
            String           toDelete;

            try
            {
                toDelete = Request.Form["row"].ToString();
            }
            catch (Exception)
            {
                toDelete = delete;
            }

            udal.userLst.RemoveRange(udal.userLst.Where(x => x.username.Equals(toDelete)));
            adal.adminsLst.RemoveRange(adal.adminsLst.Where(x => x.username.Equals(toDelete)));
            pdal.profilesList.RemoveRange(pdal.profilesList.Where(x => x.username.Equals(toDelete)));
            usdal.statuses.RemoveRange(usdal.statuses.Where(x => x.username.Equals(toDelete)));
            ndal.nLst.RemoveRange(ndal.nLst.Where(x => x.username.Equals(toDelete) || x.uFrom.Equals(toDelete)));
            fdal.FriendsLst.RemoveRange(fdal.FriendsLst.Where(x => x.username.Equals(toDelete)));
            fdal.FriendsLst.RemoveRange(fdal.FriendsLst.Where(x => x.friendUsername.Equals(toDelete)));

            udal.SaveChanges();
            adal.SaveChanges();
            pdal.SaveChanges();
            usdal.SaveChanges();
            ndal.SaveChanges();
            fdal.SaveChanges();

            return(RedirectToAction("usersList", "Admin"));
        }
예제 #2
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"));
        }
예제 #3
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"));
        }