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"));
        }
        public ActionResult UserActivity()
        {
            String      toChange = Request.Form["row"].ToString();
            usersStatus us       = new usersStatus();

            us.username = toChange;

            if (Request.Form["toDo"].Equals("Activate"))
            {
                us.status = "Activated";
            }
            else
            {
                us.status = "Deactivated";
            }

            usdal.statuses.RemoveRange(usdal.statuses.Where(x => x.username == toChange));
            usdal.SaveChanges();
            usdal.statuses.Add(us);
            usdal.SaveChanges();

            return(RedirectToAction("usersList", "Admin"));
        }