Exemple #1
0
        public ActionResult Index(string Email, string[] ListFriends)
        {
            ApplicationDbContext dbcont = new ApplicationDbContext();
            BigSearchFriendModel model  = new BigSearchFriendModel();

            model.tosendinginv = new SearchFriendModel();

            model.tosendinginv.ListFriends = ListFriends;
            model.toinivitations           = new SearchFriendModel();

            ApplicationUser user      = getUser();
            var             allusers  = dbcont.Users.ToArray();
            var             inviteeID = allusers[0].Id;

            foreach (var x in allusers)
            {
                if (x.Email.Equals(Email))
                {
                    inviteeID = x.Id;
                }
            }

            Invitation invitetoAdd = new Invitation
            {
                firstUserId  = user.Id,
                secondUserId = inviteeID
            };

            using (var db = new conferenceEntities2())
            {
                db.Invitation.Add(invitetoAdd);
                db.SaveChanges();
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult Contact()
        {
            ApplicationDbContext dbcont = new ApplicationDbContext();

            var allusers = dbcont.Users.ToArray();

            BigSearchFriendModel model = new BigSearchFriendModel();

            model.toinivitations = new SearchFriendModel();

            ApplicationUser user = getUser();

            try
            {
                ViewBag.Nick = user.Email.ToString();

                using (var db = new conferenceEntities2())
                {
                    var find = from docs in db.Invitation where docs.secondUserId == user.Id select docs;

                    var invitations = find.ToArray();



                    if (invitations.Count() > 0)
                    {
                        ViewBag.mess = invitations.Count().ToString();

                        model.toinivitations.ListFriends = new string[invitations.Count()];
                        int licz = 0;
                        foreach (var x in invitations)
                        {
                            foreach (var z in allusers)
                            {
                                if (z.Id.Equals(x.firstUserId))
                                {
                                    model.toinivitations.ListFriends.SetValue(z.Email, licz);
                                    licz++;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        ViewBag.mess = null;
                    }
                }
            }
            catch (Exception)
            {
            }

            ViewBag.Message = "Temat: Wideokonferncje";

            return(View(model));
        }
Exemple #3
0
        public ActionResult Friendrejected(string email, string[] model, string view)
        {
            ApplicationDbContext dbcont = new ApplicationDbContext();

            ApplicationUser user     = getUser();
            var             allusers = dbcont.Users.ToArray();

            BigSearchFriendModel br = new BigSearchFriendModel();

            br.toinivitations = new SearchFriendModel();

            br.toinivitations.Email       = email;
            br.toinivitations.ListFriends = model;
            var IDfr = allusers[0].Id;

            foreach (var x in allusers)
            {
                if (x.Email.Equals(email))
                {
                    IDfr = x.Id;
                    break;
                }
            }
            var        find = from docs in db.Invitation where docs.secondUserId == user.Id where docs.firstUserId == IDfr select docs;
            Invitation inv  = null;

            if (find.Any())
            {
                inv = find.First();
            }


            using (var db = new conferenceEntities2())
            {
                if (inv != null)
                {
                    db.Invitation.Attach(inv);
                    db.Invitation.Remove(inv);
                }

                db.SaveChanges();
            }
            br.tofriends = getFriends(user);

            if (view.Equals("contact"))
            {
                return(View("../Home/Contact", br));
            }
            else
            {
                return(View("../Home/Index", br));
            }
        }
Exemple #4
0
        // GET: Friends
        public ActionResult Index()
        {
            ApplicationDbContext dbcont = new ApplicationDbContext();
            BigSearchFriendModel model  = new BigSearchFriendModel();

            model.tosendinginv   = new SearchFriendModel();
            model.toinivitations = new SearchFriendModel();
            var allusers = dbcont.Users.ToArray();


            ApplicationUser user = getUser();
            int             pom  = 0;

            using (var db = new conferenceEntities2())
            {
                var find = from docs in db.Invitation where docs.firstUserId == user.Id select docs;

                var invitations = find.ToArray();

                model.tosendinginv.ListFriends = new string[allusers.Count() - 1 - invitations.Count()];
                int licz = 0;
                foreach (var x in allusers)
                {
                    licz = 0;
                    if (!x.Email.Equals(user.Email.ToString()))
                    {
                        if (invitations.Count() != 0)
                        {
                            while (invitations.Count() != licz)
                            {
                                if (!invitations[licz].secondUserId.Equals(x.Id))
                                {
                                    if (licz == invitations.Count() - 1)
                                    {
                                        model.tosendinginv.ListFriends.SetValue(x.Email, pom);
                                        pom++;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                                licz++;
                            }
                        }
                        else
                        {
                            model.tosendinginv.ListFriends.SetValue(x.Email, pom);
                            pom++;
                        }
                    }
                }
            }


            try
            {
                ViewBag.Nick = user.Email.ToString();

                using (var db = new conferenceEntities2())
                {
                    var find = from docs in db.Invitation where docs.secondUserId == user.Id select docs;

                    var invitations = find.ToArray();

                    if (invitations.Count() == 0)
                    {
                        ViewBag.pom = "yes";
                    }
                    else
                    {
                        ViewBag.pom = "no";
                    }

                    if (invitations.Count() > 0)
                    {
                        ViewBag.mess = invitations.Count().ToString();

                        model.toinivitations.ListFriends = new string[invitations.Count()];
                        int licz = 0;
                        foreach (var x in invitations)
                        {
                            foreach (var z in allusers)
                            {
                                if (z.Id.Equals(x.firstUserId))
                                {
                                    model.toinivitations.ListFriends.SetValue(z.Email, licz);
                                    licz++;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        ViewBag.mess = null;
                    }
                }
            }
            catch (Exception)
            {
            }


            return(View(model));
        }
Exemple #5
0
        public ActionResult Friendinviteaccept(string email, string[] model, string[] array)
        {
            ApplicationDbContext dbcont = new ApplicationDbContext();

            ApplicationUser user     = getUser();
            var             allusers = dbcont.Users.ToArray();

            BigSearchFriendModel br = new BigSearchFriendModel();

            br.toinivitations           = new SearchFriendModel();
            br.tosendinginv             = new SearchFriendModel();
            br.tosendinginv.ListFriends = array;

            br.toinivitations.Email       = email;
            br.toinivitations.ListFriends = model;
            var IDfr = allusers[0].Id;

            foreach (var x in allusers)
            {
                if (x.Email.Equals(email))
                {
                    IDfr = x.Id;
                    break;
                }
            }

            Friends fr1 = new Friends
            {
                firstUserId  = user.Id,
                secondUserId = IDfr
            };

            Friends fr2 = new Friends
            {
                firstUserId  = IDfr,
                secondUserId = user.Id
            };



            using (var db = new conferenceEntities2())
            {
                var        find = from docs in db.Invitation where docs.secondUserId == user.Id where docs.firstUserId == IDfr select docs;
                Invitation inv  = null;
                if (find.Any())
                {
                    inv = find.First();
                }

                db.Friends.Add(fr1);
                db.Friends.Add(fr2);
                db.SaveChanges();
                if (inv != null)
                {
                    db.Invitation.Attach(inv);
                    db.Invitation.Remove(inv);
                }

                db.SaveChanges();
            }


            return(View("../Friends/Index", br));
        }
Exemple #6
0
        public ActionResult Index(string password)
        {
            ApplicationDbContext dbcont = new ApplicationDbContext();

            var allusers = dbcont.Users.ToArray();

            BigSearchFriendModel model = new BigSearchFriendModel();

            model.toinivitations = new SearchFriendModel();

            ApplicationUser user = getUser();

            try
            {
                ViewBag.Nick = user.Email.ToString();

                using (var db = new conferenceEntities2())
                {
                    var find = from docs in db.Invitation where docs.secondUserId == user.Id select docs;

                    var invitations = find.ToArray();



                    if (invitations.Count() > 0)
                    {
                        ViewBag.mess = invitations.Count().ToString();

                        model.toinivitations.ListFriends = new string[invitations.Count()];
                        int licz = 0;
                        foreach (var x in invitations)
                        {
                            foreach (var z in allusers)
                            {
                                if (z.Id.Equals(x.firstUserId))
                                {
                                    model.toinivitations.ListFriends.SetValue(z.Email, licz);
                                    licz++;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        ViewBag.mess = null;
                    }
                }
            }
            catch (Exception)
            {
            }


            try
            {
                // sprawdzanie URL, jeśli nie rzuci wyjątku to znaczy, że użytkownik wszedł do pokoju
                string   url        = Request.Url.AbsoluteUri;
                string[] splitedUrl = url.Split('?');
                string   roomName   = splitedUrl[1];

                // sprawdzanie czy pokój isnieje
                if (roomNotExists(roomName))
                {
                    return(View("RoomNotExist"));
                }

                // inicjalizacja pustego hasła (pokój nie ma hasła)
                if (string.IsNullOrEmpty(password))
                {
                    password = "";
                }

                // sprawdzanie hasła do pokoju
                if (checkPass(roomName, password))
                {
                    using (var db = new conferenceEntities2())
                    {
                        // usuwanie zaproszeń do pokoju (jeśli były)
                        int roomId           = db.Rooms.First(r => r.name == roomName).roomId;
                        var invitationsArray = (from invit in db.RoomsInvitations
                                                where invit.invitee == user.Id && invit.roomId == roomId
                                                select invit).ToArray();
                        foreach (var i in invitationsArray)
                        {
                            db.RoomsInvitations.Remove(i);
                        }//foreach
                        db.SaveChanges();

                        // dodawanie uzytkownika do aktywnego pokoju
                        addUserToRoom(roomId, user.Id);
                    }//using

                    // lista znajomych
                    model.tofriends = getFriends(getUser());

                    return(View(model));
                }//if

                ViewBag.roomName = roomName;
                ViewBag.pass     = password;
                try
                {
                    ViewBag.Nick = user.Email.ToString();
                }
                catch (NullReferenceException)
                {
                    // nic nie rób
                }
                return(View("RoomPassword"));
            }//try
            catch (IndexOutOfRangeException)
            {
                // nic nie rób
            }

            // jeśli użytkownik jest zalogowany to wyświetl mu listę znajomych
            if (user != null)
            {
                model.tofriends = getFriends(user);
                return(View(model));
            }//if

            return(View());
        }