Exemplo n.º 1
0
        // GET: /Profile/
        public ActionResult Index()
        {
            var currentUser = UserDB.Users.Find(User.Identity.GetUserId());

            if (currentUser.MadeProfileYet)
            {
                var vm = new ProfileStatusVM();
                vm.StatusList = new List <Status>();

                Guid UserId  = new Guid(User.Identity.GetUserId());
                var  profile = db.Profile.FirstOrDefault(x => x.AspNetUser_Id == UserId);
                vm.Profile = profile;
                var listOfAllStatuses = db.Status.ToList();
                var listOfUserStatus  = (from x in listOfAllStatuses
                                         where x.UserWhomStatusBelongsTo == profile.Id
                                         select x).ToList();

                foreach (var entry in listOfUserStatus)
                {
                    vm.StatusList.Add(entry);
                }
                if (vm.StatusList.Count == 0)
                {
                    Status firstStatus = new Status();
                    firstStatus.StatusUpdate            = "Welcome!";
                    firstStatus.TimeOfUpdate            = DateTime.Now;
                    firstStatus.UserWhomStatusBelongsTo = profile.Id;
                    firstStatus.UpdatedByFullName       = "Admin";
                    db.Status.Add(firstStatus);
                    vm.StatusList.Add(firstStatus);
                    db.SaveChanges();
                    //vm.StatusList.Add(new Status { StatusUpdate = "Welcome!", UserWhomStatusBelongsTo = profile.Id, UpdatedByFullName = profile.FullName, TimeOfUpdate = DateTime.Now });
                }

                return(View(vm));
            }
            else
            {
                return(RedirectToAction("MakeProfile"));
            }
        }
Exemplo n.º 2
0
        //GET
        public ActionResult ShowFriends(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Profile profile = db.Profile.Find(id);

            if (profile == null)
            {
                return(HttpNotFound());
            }
            var vm = new ProfileStatusVM();

            vm.StatusList        = new List <Status>();
            vm.ProfileCollection = new List <Profile>();
            vm.ProfileCollection = db.Profile.ToList();
            vm.ProfileCollection.Remove(profile);
            vm.StatusList = db.Status.ToList();
            return(View(vm));
        }