Example #1
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));
        }
Example #2
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));
        }