예제 #1
0
        public ActionResult DeleteFriend(string username)
        {
            List <userMoments> myList       = (List <userMoments>)Session["UsersList"];
            List <Profile>     SELECTEDLIST = (List <Profile>)Session["SelectedList"];
            List <Profile>     templist     = SELECTEDLIST;
            userMomentDal      usermdal     = new userMomentDal();
            profileDal         pDal         = new profileDal();
            var idtodelete = 0;

            foreach (var x in myList)
            {
                if (x.username == username)
                {
                    idtodelete = x.id;
                }
            }
            var ifuserexit = usermdal.userMomentLST.Where(x => (username == x.username) &&
                                                          x.uType == "User" && idtodelete == x.id).SingleOrDefault();

            if (ifuserexit != null)
            {
                usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => (x.id == idtodelete) && (x.username == username)));
                usermdal.SaveChanges();
                Profile todelete = templist.Find(x => x.username == username);
                templist.Remove(todelete);
            }
            else
            {
                TempData["CurrentMessage"] = "You Cant Delete Your Self From This Group!";
                return(View("View_All_Group_Members", SELECTEDLIST));
            }
            return(View("View_All_Group_Members", templist));
        }
예제 #2
0
        public ActionResult Promotion_to_admin(int mid2, int id)
        {
            userMomentDal      usermdal   = new userMomentDal();
            List <userMoments> usersiwant = (from x in usermdal.userMomentLST where (x.mid.Equals(mid2) && x.id.Equals(id)) select x).ToList <userMoments>();

            if (usersiwant.Count() > 0)
            {
                userMoments useriwant1 = usersiwant[0];
                usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => x.mid == useriwant1.mid && x.id == useriwant1.id));
                usermdal.SaveChanges();
                userMoments newuser = new userMoments();
                newuser.GroupName = useriwant1.GroupName;
                newuser.id        = useriwant1.id;
                newuser.image     = useriwant1.image;
                newuser.IsPublic  = useriwant1.IsPublic;
                newuser.mid       = useriwant1.mid;
                newuser.username  = useriwant1.username;
                newuser.uType     = "Admin";
                usermdal.userMomentLST.Add(newuser);
                usermdal.SaveChanges();
            }
            else
            {
                TempData["ErrorFound"] = "Cannot Found User";
            }

            return(View("UserMainPage"));
        }
예제 #3
0
        public static bool isMember(string username, int mid)
        {
            userMomentDal      mDal = new userMomentDal();
            List <userMoments> tmp  = (from x in mDal.userMomentLST
                                       where x.mid == mid &&
                                       x.username.Equals(username)
                                       select x).ToList <userMoments>();

            if (tmp.Count > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #4
0
        public ActionResult RunCreateGroup(moments obj)
        {
            int    counter;
            string MomentName        = Request.Form["MomentName"].ToString();
            string MomentDescription = Request.Form["MomentDescription"].ToString();
            string getthemaxnumber   = Request.Form["Momentmaxnumber"].ToString();

            Session["getthemaxnumber"] = getthemaxnumber;
            var authToken = new byte[16];

            byte[] Momentimage = authToken;

            userMomentDal usrmomentsdal = new userMomentDal();
            momentsDal    moments       = new momentsDal();

            List <moments> momentsID = (from tmp in moments.momentsLst select tmp).ToList <moments>();

            if (momentsID.Count == 0)
            {
                counter = 1;
            }
            else
            {
                counter = moments.momentsLst.Max(x => x.mid) + 1;
            }

            moments added_moment = new moments();

            added_moment.mid          = 1;
            added_moment.mImage       = Momentimage;
            added_moment.mName        = MomentName;
            added_moment.mDescription = MomentDescription;
            moments.momentsLst.Add(added_moment);
            moments.SaveChanges();

            users       u          = GetUser();
            userMoments usermoment = new userMoments();

            usermoment.username    = u.username;
            Session["mid"]         = counter;
            usermoment.mid         = counter;
            usermoment.GroupName   = MomentName;
            Session["MomentName1"] = MomentName;
            Session["getmidd"]     = usermoment.mid;
            usermoment.uType       = "Admin";
            umd.userMomentLST.Add(usermoment);
            umd.SaveChanges();

            return(View("AddMembersToGroup"));
        }
예제 #5
0
        public ActionResult joinAccepted()
        {
            string               username = Request.Form["username"];
            string               uFrom    = Request.Form["uFrom"];
            int                  id       = Convert.ToInt32(Request.Form["id"]);
            Notifications        n        = new Notifications();
            notificationsDal     nDal     = new notificationsDal();
            int                  size     = (from x in nDal.nLst select x).ToList <Notifications>().Count() + 1;
            List <Notifications> tmp      = (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();
            tmp[0].status = "Accepted";
            nDal.nLst.Add(tmp[0]);
            nDal.SaveChanges();
            n.id       = id;
            n.dateSent = DateTime.Now.Date;
            n.status   = "Return Accepted";
            n.type     = tmp[0].type;
            n.uFrom    = username;
            n.username = uFrom;
            nDal.nLst.Add(n);
            nDal.SaveChanges();
            int           mid       = Convert.ToInt32((tmp[0].type.Split(' '))[1]);
            userMomentDal mDal      = new userMomentDal();
            userMoments   uM        = new userMoments();
            momentsDal    d         = new momentsDal();
            string        groupName = (from x in d.momentsLst
                                       where x.mid == mid
                                       select x).ToList <moments>()[0].mName;
            int tableId = (from x in mDal.userMomentLST
                           select x).ToList <userMoments>().Count() + 1;

            uM.id        = tableId;
            uM.GroupName = groupName;
            uM.mid       = mid;
            uM.uType     = "User";
            uM.username  = uFrom;
            mDal.userMomentLST.Add(uM);
            mDal.SaveChanges();

            return(RedirectToAction("showNotifications", "Notifications"));
        }
예제 #6
0
        public ActionResult UserMoments()
        {
            classActive("momentsActive");
            users corruser = new users();

            corruser = GetUser();
            userMomentDal dusernames     = new userMomentDal();
            momentsDal    md             = new momentsDal();
            userMoments   useromoentsobj = new userMoments();

            momentsDal moments = new momentsDal();

            List <userMoments> allmomentsusehave = (from tmp in dusernames.userMomentLST
                                                    where corruser.username.Equals(tmp.username)
                                                    select tmp).ToList <userMoments>();

            return(View(allmomentsusehave));
        }
예제 #7
0
        void clear_data_from_database()
        {
            userMomentDal d  = new userMomentDal();
            momentsDal    d1 = new momentsDal();

            //usersDal user1 = new usersDal();
            foreach (var entity in d.userMomentLST)
            {
                d.userMomentLST.Remove(entity);
            }
            d.SaveChanges();
            foreach (var entity in d1.momentsLst)
            {
                d1.momentsLst.Remove(entity);
            }
            d1.SaveChanges();
            //foreach (var entity in user1.userLst)
            //   user1.userLst.Remove(entity);
            //  user1.SaveChanges();
        }
예제 #8
0
        public ActionResult JoinRequest()
        {
            userMomentDal      mDal      = new userMomentDal();
            int                mid       = Convert.ToInt32(Request.Form["mid"]);
            List <userMoments> findAdmin = (from x in mDal.userMomentLST
                                            where x.mid == mid &&
                                            x.uType.Equals("Admin")
                                            select x).ToList <userMoments>();
            string           adminUsr = findAdmin[0].username;
            notificationsDal nDal     = new notificationsDal();
            Notifications    n        = new Notifications();

            n.uFrom    = UserController.user.username;
            n.username = adminUsr;
            n.dateSent = DateTime.Now.Date;
            n.id       = (from x in nDal.nLst select x).ToList <Notifications>().Count + 1;
            n.type     = "Join " + mid;
            n.status   = "Not Accepted";
            nDal.nLst.Add(n);
            nDal.SaveChanges();
            return(RedirectToAction("UserMoments", "User"));
        }
예제 #9
0
        public ActionResult ExitGroup(int id, int mid1)
        {
            users corruser = new users();

            corruser = GetUser();
            userMomentDal usermdal    = new userMomentDal();
            momentsDal    momentsmdal = new momentsDal();

            var getifuserUser = usermdal.userMomentLST.Where(x => (corruser.username == x.username) &&
                                                             x.uType == "User" && id == x.id).SingleOrDefault();


            var getifuseradmin = usermdal.userMomentLST.Where(x => (corruser.username == x.username) &&
                                                              x.uType == "Admin" && id == x.id).SingleOrDefault();

            /* List<userMoments> allmomentsusehave = (from tmp in dusernames.userMomentLST
             *                                    where corruser.username.Equals(tmp.username)
             *                                    select tmp).ToList<userMoments>();*/


            if (getifuseradmin != null)
            {
                List <userMoments> allmomentsusehave = (from tmp in usermdal.userMomentLST
                                                        where id.Equals(tmp.mid)
                                                        select tmp).ToList <userMoments>();

                usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => x.mid == mid1));
                usermdal.SaveChanges();
                momentsmdal.momentsLst.RemoveRange(momentsmdal.momentsLst.Where(x => x.mid == mid1));
                momentsmdal.SaveChanges();
            }
            else if (getifuserUser != null)
            {
                usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => (x.mid == mid1) && (x.username == corruser.username)));
                usermdal.SaveChanges();
            }
            return(RedirectToAction("UserMoments", "User"));
        }
예제 #10
0
        public ActionResult Permission_Members(int mid1)
        {
            userMomentDal      usermdal         = new userMomentDal();
            var                qr               = (from x in usermdal.userMomentLST where x.mid == mid1 select x.username).ToArray();
            List <userMoments> AllUsers         = (from x in usermdal.userMomentLST select x).ToList <userMoments>();
            List <userMoments> usersiwant       = (from x in usermdal.userMomentLST where x.mid.Equals(mid1) select x).ToList <userMoments>();
            List <userMoments> usersinthisgroup = new List <userMoments>();

            var size = qr.Count();

            foreach (var z in AllUsers)
            {
                for (int v = 0; v < size; v++)
                {
                    if (z.username == qr[v])
                    {
                        usersinthisgroup.Add(z);
                    }
                }
            }
            Session["UsersList"] = usersinthisgroup;
            return(View("Permission_For_Members", usersiwant));
        }
예제 #11
0
        public ActionResult EditGroupName()
        {
            var            getgroupnewname = Request.Form["editgroupname"].ToString();
            int            mid2            = Convert.ToInt32(Session["correntMid"]);
            momentsDal     md          = new momentsDal();
            userMomentDal  umd         = new userMomentDal();
            List <moments> litsofallmd = (from tmp in md.momentsLst where tmp.mid.Equals(mid2) select tmp).ToList <moments>();
            var            toedit      = md.momentsLst.Where(f => f.mid.Equals(mid2)).ToList();

            if (litsofallmd.Count > 0)
            {
                if (litsofallmd[0].mName != getgroupnewname)
                {
                    toedit.ForEach(a => a.mName = getgroupnewname);
                    md.SaveChanges();
                    List <userMoments> membersofthisgroup = (from tmp in umd.userMomentLST where tmp.mid.Equals(mid2) select tmp).ToList <userMoments>();
                    foreach (var x in membersofthisgroup)
                    {
                        umd.userMomentLST.Remove(x);
                        userMoments toadd1 = new userMoments();
                        toadd1.id        = x.id;
                        toadd1.GroupName = getgroupnewname;
                        toadd1.mid       = x.mid;
                        toadd1.username  = x.username;
                        toadd1.uType     = x.uType;
                        umd.userMomentLST.Add(toadd1);
                        umd.SaveChanges();
                    }
                    TempData["ErrorMessageEdit"] = "Your Group Name Has Been Edited Sucessfully";
                    return(View("EditGroupName"));
                }
            }
            {
                TempData["ErrorMessageEdit"] = "You Have A Problem With Group Name , Please Enter New Name";
                return(View("EditGroupName"));
            }
        }
예제 #12
0
        public ActionResult View_All_Group_Members(int mid1)
        {
            profileDal         pDal             = new profileDal();
            userMomentDal      usermdal         = new userMomentDal();
            var                qr               = (from x in usermdal.userMomentLST where x.mid == mid1 select x.username).ToArray();
            List <Profile>     allprofiles      = (from x in pDal.profilesList select x).ToList <Profile>();
            List <userMoments> AllUsers         = (from x in usermdal.userMomentLST select x).ToList <userMoments>();
            List <Profile>     selected         = new List <Profile>();
            List <userMoments> usersinthisgroup = new List <userMoments>();

            var size = qr.Count();

            foreach (var z in AllUsers)
            {
                for (int v = 0; v < size; v++)
                {
                    if (z.username == qr[v])
                    {
                        usersinthisgroup.Add(z);
                    }
                }
            }
            Session["UsersList"] = usersinthisgroup;
            foreach (var z in allprofiles)
            {
                for (int v = 0; v < size; v++)
                {
                    if (z.username == qr[v])
                    {
                        selected.Add(z);
                    }
                }
            }
            Session["SelectedList"] = selected;
            return(View(selected));
        }
예제 #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));
            }
        }