コード例 #1
0
        // GET: Friendships
        public ActionResult Index()
        {
            var            DB          = new CasaDoPaoDeQueijoContainer();
            string         Email       = User.Identity.GetEmailAdress();
            List <Profile> friends     = new List <Profile>();
            var            profile     = DB.ProfileSet.FirstOrDefault(x => x.Email == Email);
            var            friendships = DB.FriendshipSet.Where(x => x.FirstUser == profile.Id || x.SecondUser == profile.Id && x.Accepted == true);

            foreach (var friendship in friendships)
            {
                if (friendship.FirstUser == profile.Id)
                {
                    friends = DB.ProfileSet.Where(x => x.Id == friendship.SecondUser).ToList();
                }
                else
                {
                    List <Profile> friends2 = DB.ProfileSet.Where(x => x.Id == friendship.FirstUser).ToList();
                    foreach (var friend in friends2)
                    {
                        friends.Add(friend);
                    }
                }
            }
            return(View(db.FriendshipSet.ToList()));
        }
コード例 #2
0
        // GET: Feed
        public ActionResult Index()
        {
            var    DB      = new CasaDoPaoDeQueijoContainer();
            string Email   = User.Identity.GetEmailAdress();
            var    profile = DB.ProfileSet.FirstOrDefault(x => x.Email == Email);
            var    posts   = DB.PostSet.Where(x => x.ProfileId == profile.Id);

            return(View());
        }
コード例 #3
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            var    DB    = new CasaDoPaoDeQueijoContainer();
            string Email = User.Identity.GetEmailAdress();

            Session["UserEmail"] = Email;
            try
            {
                var profile = DB.ProfileSet.FirstOrDefault(x => x.Email == Email);
                if (profile == null)
                {
                    Session["UserId"] = null;
                }
                else
                {
                    if (User.Identity.IsAuthenticated)
                    {
                        Session["UserId"] = profile.Id;
                    }
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = e.ToString();
                return(View("Error"));
            }

            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Sua senha foi alterada."
                : message == ManageMessageId.SetPasswordSuccess ? "Sua senha foi definida."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Seu provedor de autenticação de dois fatores foi definido."
                : message == ManageMessageId.Error ? "Ocorreu um erro."
                : message == ManageMessageId.AddPhoneSuccess ? "Seu número de telefone foi adicionado."
                : message == ManageMessageId.RemovePhoneSuccess ? "Seu número de telefone foi removido."
                : "";

            var userId = User.Identity.GetUserId();
            var model  = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins            = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
            };

            return(View(model));
        }