Exemple #1
0
        public ActionResult Followers()
        {
            var idCard = ((System.Web.HttpContext.Current.User as MyIdentity.MyPrincipal).Identity as MyIdentity).User.IdCard;
            var model  = new FollowersViewModel();
            List <PR_GetFollowers_Result> customers = db.PR_GetFollowers(idCard).ToList();

            if (customers.Count == 0)
            {
                TempData["NoFollowers"] = "You do not have any subscriber yet :(";
            }
            List <ProfileModel> profileModels = new List <ProfileModel>();

            foreach (var account in customers)
            {
                var profile = new ProfileModel();
                profile.IdCard    = account.IdCard;
                profile.Username  = account.Username;
                profile.FirstName = account.FirstName;
                profile.LastName  = account.LastName;
                profile.LastName  = account.LastName;

                ObjectParameter followersQty = new ObjectParameter("Qty", typeof(int));
                db.PR_GetFollowersCount(account.IdCard, followersQty);
                profile.Followers = (int)followersQty.Value;
                profile.Reviews   = db.Customer.Find(account.IdCard).Review.Count;
                profileModels.Add(profile);
            }
            model.Customers = profileModels;
            return(View(model));
        }
Exemple #2
0
        public ActionResult UserProfile()
        {
            var                  identity   = (System.Web.HttpContext.Current.User as MyIdentity.MyPrincipal).Identity as MyIdentity;
            User                 loggedUser = db.User.Find(identity.User.IdCard);
            Customer             customer   = db.Customer.FirstOrDefault(a => a.IdCard.Equals(identity.User.IdCard));
            ProfileEditViewModel model      = new ProfileEditViewModel();

            model.Activity = "active";
            model.Settings = "";
            model.Change   = "";

            ObjectParameter followersQty = new ObjectParameter("Qty", typeof(int));

            db.PR_GetFollowersCount(identity.User.IdCard, followersQty);


            ObjectParameter followingQty = new ObjectParameter("Qty", typeof(int));

            db.PR_GetFriendsCount(identity.User.IdCard, followingQty);


            model.profileData = new ProfileViewModel
            {
                Username       = loggedUser.Username,
                IdCard         = loggedUser.IdCard,
                FirstName      = loggedUser.FirstName,
                MiddleName     = loggedUser.MiddleName,
                LastName       = loggedUser.LastName,
                SecondLastName = loggedUser.SecondLastName,
                Gender         = loggedUser.Gender,
                BirthDate      = loggedUser.BirthDate,
                Nationality    = loggedUser.Nationality,
                AccountNumber  = customer.AccountNumber,
                Followers      = (int)followersQty.Value,
                Following      = (int)followingQty.Value,
                Reviews        = customer.Review.Count
            };
            model.Timeline = db.Review.Where(r => r.IdCustomer == identity.User.IdCard).OrderByDescending(review => review.Date).ToList();

            ViewBag.Nationality = new SelectList(db.Country, "IdCountry", "Name", loggedUser.Nationality);
            return(View(model));
        }