コード例 #1
0
        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 PublicPhoto()
        {
            classActive("publicActive");
            friendsDal     fd       = new friendsDal();
            string         username = Session["CurrentUsername"].ToString();
            List <Friends> curr     = (from x in fd.FriendsLst
                                       where (x.username.Equals(username)) || (x.friendUsername.Equals(username))
                                       select x).ToList <Friends>();
            List <string> friendsUserName = new List <string>();

            friendsUserName.Add(username);
            foreach (var friend in curr)
            {
                if (friend.username.Equals(username))
                {
                    friendsUserName.Add(friend.friendUsername);
                }
                else
                {
                    friendsUserName.Add(friend.username);
                }
            }
            PublicMomentPhotoView    pmpv   = new PublicMomentPhotoView();
            publicMomentPhotoDal     pmpd   = new publicMomentPhotoDal();
            List <publicMomentPhoto> photos = (from x in pmpd.momentPhotoLst
                                               where   friendsUserName.Any(item => item.Equals(x.username))
                                               select x).ToList <publicMomentPhoto>();

            pmpv.publicMomentphotos = photos;
            pmpv.photo = "photo";
            return(View(pmpv));
        }
コード例 #3
0
        public ActionResult Delete(String id)
        {
            String         uname    = Session["CurrentUsername"].ToString();
            friendsDal     fDal     = new friendsDal();
            List <Friends> friendsd = (from x in fDal.FriendsLst
                                       where (x.username.Equals(uname) && x.friendUsername.Equals(id)) ||
                                       (x.friendUsername.Equals(uname) && x.username.Equals(id))
                                       select x).ToList <Friends>();

            fDal.FriendsLst.Remove(friendsd[0]);
            fDal.SaveChanges();
            List <String> friends1 = (from x in fDal.FriendsLst
                                      where x.username.Equals(uname)
                                      select x.friendUsername).ToList <String>();

            List <String> friends2 = (from x in fDal.FriendsLst
                                      where x.friendUsername.Equals(uname)
                                      select x.username).ToList <String>();
            IEnumerable <String> friends  = friends1.Union(friends2);
            profileDal           pDal     = new profileDal();
            List <Profile>       profiles = (from x in pDal.profilesList
                                             where friends.Contains <String>(x.username)
                                             select x).ToList <Profile>();

            return(View("MyFriends", profiles));
        }
コード例 #4
0
        public ActionResult AddFriend(String id)
        {
            notificationsDal     nDal = new notificationsDal();
            List <Notifications> tmp  = (from x in nDal.nLst
                                         select x).ToList <Notifications>();
            int           size    = tmp.Count();
            Notifications newNoti = new Notifications();

            newNoti.username = id;
            newNoti.status   = "Not Accepted";
            newNoti.uFrom    = Session["CurrentUsername"].ToString();
            newNoti.dateSent = DateTime.Now;
            newNoti.type     = "Friend Request";
            newNoti.id       = size + 1;

            nDal.nLst.Add(newNoti);
            nDal.SaveChanges();


            friendsDal     fDal     = new friendsDal();
            String         uname    = Session["CurrentUsername"].ToString();
            List <Friends> friends1 = (from x in fDal.FriendsLst
                                       where x.username.Equals(uname)
                                       select x).ToList <Friends>();

            List <Friends> friends2 = (from x in fDal.FriendsLst
                                       where x.friendUsername.Equals(uname)
                                       select x).ToList <Friends>();
            IEnumerable <Friends> friendAll = friends1.Union(friends2);
            List <String>         friends   = new List <string>();

            foreach (var f in friendAll)
            {
                if (f.username.Equals(uname))
                {
                    friends.Add(f.friendUsername);
                }
                else
                {
                    friends.Add(f.username);
                }
            }

            //IEnumerable<Friends> friends = friends1.Union(friends2);
            profileDal     pDal     = new profileDal();
            List <Profile> profiles = (from x in pDal.profilesList
                                       where friends.Contains <String>(x.username)
                                       select x).ToList <Profile>();

            return(View("MyFriends", profiles));
        }
コード例 #5
0
        public ActionResult AddPublicPhoto(IEnumerable <HttpPostedFileBase>
                                           imageModel)
        {
            byte[] data;
            using (Stream inputStram = Request.Files[0].InputStream)
            {
                MemoryStream memorystram = inputStram as MemoryStream;
                if (memorystram == null)
                {
                    memorystram = new MemoryStream();
                    inputStram.CopyTo(memorystram);
                }
                publicMomentPhotoDal mpd1 = new publicMomentPhotoDal();
                publicMomentPhoto    mp   = new publicMomentPhoto();
                data        = memorystram.ToArray();
                mp.photo    = data;
                mp.username = Session["CurrentUsername"].ToString();
                mpd1.momentPhotoLst.Add(mp);
                mpd1.SaveChanges();
                ViewData["photo"] = "Photo Added";
            }
            friendsDal     fd       = new friendsDal();
            string         username = Session["CurrentUsername"].ToString();
            List <Friends> curr     = (from x in fd.FriendsLst
                                       where (x.username.Equals(username)) || (x.friendUsername.Equals(username))
                                       select x).ToList <Friends>();
            List <string> friendsUserName = new List <string>();

            friendsUserName.Add(username);
            foreach (var friend in curr)
            {
                if (friend.username.Equals(username))
                {
                    friendsUserName.Add(friend.friendUsername);
                }
                else
                {
                    friendsUserName.Add(friend.username);
                }
            }
            PublicMomentPhotoView    pmpv   = new PublicMomentPhotoView();
            publicMomentPhotoDal     pmpd   = new publicMomentPhotoDal();
            List <publicMomentPhoto> photos = (from x in pmpd.momentPhotoLst
                                               where friendsUserName.Any(item => item.Equals(x.username))
                                               select x).ToList <publicMomentPhoto>();

            pmpv.publicMomentphotos = photos;
            pmpv.photo = "photo";
            return(View("PublicPhoto", pmpv));
        }
コード例 #6
0
        public ActionResult AddFriendAccepted()
        {
            string         u1           = Request.Form["u1"].ToString();
            string         u2           = Request.Form["u2"].ToString();
            int            id           = Convert.ToInt32(Request.Form["id"]);
            friendsDal     fDal         = new friendsDal();
            List <Friends> checkFriends = (from x in fDal.FriendsLst
                                           where (x.username.Equals(u1) && x.friendUsername.Equals(u2)) ||
                                           (x.username.Equals(u2) && x.friendUsername.Equals(u1))
                                           select x).ToList <Friends>();
            Friends f = new Friends();

            f.username       = u1;
            f.friendUsername = u2;
            fDal.FriendsLst.Add(f);
            fDal.SaveChanges();
            Notifications        n    = new Notifications();
            notificationsDal     nDal = new notificationsDal();
            List <Notifications> nots = (from x in nDal.nLst select x).ToList();
            List <Notifications> prev = (from x in nDal.nLst
                                         where x.id == id
                                         select x).ToList <Notifications>();

            nDal.nLst.RemoveRange(nDal.nLst.Where(x => x.id == id));
            nDal.SaveChanges();
            n.id       = id;
            n.status   = "Accepted";
            n.type     = "Friend Request";
            n.username = u1;
            n.uFrom    = u2;
            n.dateSent = DateTime.Now;
            n.dateSent = n.dateSent.Date;
            nDal.nLst.Add(n);
            nDal.SaveChanges();
            n = new Notifications
            {
                dateSent = DateTime.UtcNow,
                id       = nots.Count() + 1,
                type     = "Friend Request",
                status   = "Return Accepted",
                username = u2,
                uFrom    = u1
            };
            nDal.nLst.Add(n);
            nDal.SaveChanges();

            return(RedirectToAction("showNotifications", "Notifications"));
        }
コード例 #7
0
        public static bool isFriend(string id)
        {
            bool           friendCheck = false;
            friendsDal     fDal        = new friendsDal();
            List <Friends> f           = (from x in fDal.FriendsLst
                                          where x.username.Equals(user.username) || x.friendUsername.Equals(user.username)
                                          select x).ToList <Friends>();
            List <Friends> tmp = new List <Friends>();

            foreach (Friends fr in f)
            {
                if (fr.username.Equals(id) || fr.friendUsername.Equals(id))
                {
                    tmp.Add(fr);
                }
            }
            if (tmp.Count() > 0)
            {
                friendCheck = true;
            }
            return(friendCheck);
        }
コード例 #8
0
        public ActionResult MyFriends()
        {
            classActive("friendsActive");
            friendsDal fDal  = new friendsDal();
            String     uname = Session["CurrentUsername"].ToString();

            Debug.WriteLine(uname);
            List <Friends> friends1 = (from x in fDal.FriendsLst
                                       where x.username.Equals(uname)
                                       select x).ToList <Friends>();

            List <Friends> friends2 = (from x in fDal.FriendsLst
                                       where x.friendUsername.Equals(uname)
                                       select x).ToList <Friends>();
            IEnumerable <Friends> friendAll = friends1.Concat <Friends>(friends2);
            List <String>         friends   = new List <string>();

            foreach (var f in friendAll)
            {
                if (f.username.Equals(uname))
                {
                    friends.Add(f.friendUsername);
                }
                else
                {
                    friends.Add(f.username);
                }
            }
            //Debug.WriteLine(friends[0]);
            //IEnumerable<Friends> friends = friends1.Union(friends2);
            profileDal     pDal     = new profileDal();
            List <Profile> profiles = (from x in pDal.profilesList
                                       where friends.Contains <String>(x.username)
                                       select x).ToList <Profile>();

            return(View(profiles));
        }