public ActionResult UserProfile(string userID = "")
        {
            var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
           
            string getID = userID == "" ? User.Identity.GetUserId() : userID;
            string currentUser = User.Identity.GetUserId();
            //var currentUser = manager.FindById(getID);
            var YATUser = new User();
            Connections conn = new Connections();
            using (var dbContext = new YATContext())
            {
               YATUser = dbContext.User.Where(p => p.Id.Contains(getID)).FirstOrDefault();
               conn=  dbContext.Connections.Where(o => o.FromId == currentUser && o.ToId == getID).FirstOrDefault();
            }

            //Disable hide and blocked buttons if already hidden or blocked
            


            if (conn !=null)
            {
                ViewBag.Blocked = conn.IsBlocked;
                ViewBag.Hidden = conn.IsRemoved;
            }
            else
            {
                ViewBag.Blocked = false;
                ViewBag.Hidden = false;
            }
            return View(YATUser); 
        }
        public ActionResult UpdateConnection(string buttonName, string ToUser)
        {
            var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
          //  var currentUser = manager.FindById(User.Identity.GetUserId());
            var currentUser = User.Identity.GetUserId();
          //  User fromUser;

            //using (var dbContext = new YATContext())
            //{
            //    fromUser = dbContext.User.Where(p => p.Id.Contains(currentUser.Id)).FirstOrDefault();
            //}
          //  var user = db.User.Find(ToUser);
            //check if connection entry exists for the 2 users
               Connections conn = new Connections();
          //  if (db.Connections.Any(o => o.FromId == currentUser && o.ToId==ToUser ))
           conn=  db.Connections.Where(o => o.FromId == currentUser && o.ToId == ToUser).FirstOrDefault();
            if (conn!=null)
            {
                if (buttonName == "Block" )
                    conn.IsBlocked = true;
                else
                    conn.IsRemoved=true;   
            }
            else //create new entry
            {
              Connections conn2 = new Connections()
                {
                    ToId = ToUser,
                    FromId = currentUser,
                    IsBlocked = (buttonName == "Block") ? true : false,
                    IsRemoved = (buttonName == "Hide") ? true : false
                };
                db.Connections.Add(conn2);
            }
                db.SaveChanges();

            return RedirectToAction("UserProfile", new { userID = ToUser });
        }
        public void putData()
        {
            using (var dbContext = new YATContext())
            {
                User paul = dbContext.User.Where(p => p.FirstName.Contains("Paul")).FirstOrDefault();
                if (paul != null)
                {
                    return;
                }

                paul = new User
                {
                    Id = "1",
                    Address = "11791",
                    FirstName = "Paul",
                    LastName = "Sultan",
                    Age = 28,
                    Gender = true,
                    Deleted = false,
                    InterestedIn = false,
                    Photo = "male.jpg",
                    RegistrationDate = Convert.ToDateTime("01/11/2015"),
                    LastLoginDate = DateTime.Now,
                };
                var mike = new User
                {
                    Address = "11791",
                    FirstName = "Mike",
                    LastName = "Sultan",
                    Age = 28,
                    Gender = true,
                    Deleted = false,
                    InterestedIn = false,
                    Photo = "male.jpg",
                    RegistrationDate = Convert.ToDateTime("01/10/2015"),
                    LastLoginDate = DateTime.Now,
                };
                var sue = new User
                {
                    Address = "10010",
                    FirstName = "Sue",
                    LastName = "Flower",
                    Age = 28,
                    Gender = false,
                    Deleted = false,
                    InterestedIn = true,
                    Photo = "female.jpg",
                    RegistrationDate = Convert.ToDateTime("04/10/2015"),
                    LastLoginDate = DateTime.Now,
                };
                var Ariel = new User
                {
                    Id = "d",
                    Address = "94101",
                    FirstName = "Brad",
                    LastName = "Gabe",
                    Age = 30,
                    Gender = true,
                    Deleted = false,
                    InterestedIn = false,
                    Photo = "male.jpg",
                    RegistrationDate = Convert.ToDateTime("04/10/2015"),
                    LastLoginDate = DateTime.Now,
                };
                dbContext.User.Add(paul);
                dbContext.User.Add(mike);
                dbContext.User.Add(sue);
                dbContext.User.Add(Ariel);
            
                var gump = new Likes { Movie = "Forest Gump" };
                var nemo = new Likes { Movie = "Finding Nemo" };
                var avengers = new Likes { Movie = "Avengers" };
                mike.Likes.Add(nemo);
                mike.Likes.Add(gump);
                paul.Likes.Add(nemo);
                sue.Likes.Add(avengers);
                sue.Likes.Add(gump);

                Likes movie = dbContext.Likes.FirstOrDefault(L => L.Movie == "Avengers");
                Ariel.Likes.Add(movie);

                var sueConnection = new Connections { From = sue, To = mike, IsBlocked = true, IsRemoved=false };
                var sueConnection2 = new Connections { From = sue, To = paul, IsBlocked=false, IsRemoved = true };
                dbContext.Connections.Add(sueConnection);
                dbContext.Connections.Add(sueConnection2);
                
                var message = new Message
                {
                    Text = "Hi there",
                    From = mike,
                    To = sue,
                    Date = DateTime.Now,
                    Read = false
                };
                var reply = new Message
                {
                    Text = "Hello",
                    From = sue,
                    To = mike,
                    Date = DateTime.Now.AddMinutes(5),
                    Read = false
                };
                var repAgain = new Message
                {
                    Text = "wanna go program some tests??!?!!",
                    From = mike,
                    To = sue,
                    Date = DateTime.Now.AddMinutes(8),
                    Read = false
                };
                var anotherMessage = new Message
                {
                    Text = "something awesome",
                    From = Ariel,
                    To = sue,
                    Date = DateTime.Now,
                    Read = false
                };
                dbContext.Messages.Add(message);
                dbContext.Messages.Add(reply);
                dbContext.Messages.Add(repAgain);
                dbContext.SaveChanges();
            }
        }