// GET: /Profile/ public ActionResult Index() { var currentUser = UserDB.Users.Find(User.Identity.GetUserId()); if (currentUser.MadeProfileYet) { var vm = new ProfileStatus(); vm.StatusList = new List<Status>(); Guid UserId = new Guid(User.Identity.GetUserId()); var profile = db.UserProfiles.FirstOrDefault(x => x.AspNetUser_Id == UserId); vm.Profile = profile; var listOfAllStatuses = db.Statuses.ToList(); var listOfUserStatus = new List<Status>(); foreach (Status x in listOfAllStatuses) { if (x.UserWhomStatusBelongsTo == profile.Id) listOfUserStatus.Add(x); } foreach (var entry in listOfUserStatus) vm.StatusList.Add(entry); if (vm.StatusList.Count == 0) { Status firstStatus = new Status(); Profile aProfile= new Profile(); firstStatus.StatusUpdate = "Welcome!"; firstStatus.TimeOfUpdate = DateTime.Now; firstStatus.UserWhomStatusBelongsTo = aProfile.AspNetUser_Id ; firstStatus.UpdatedByFullName = aProfile.FullName; db.Statuses.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("CreateProfile"); }
//GET public ActionResult ShowFriends(Guid? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Profile profile = db.UserProfiles.Find(id); if (profile == null) { return HttpNotFound(); } var vm = new ProfileStatus(); vm.StatusList = new List<Status>(); vm.ProfileCollection = new List<Profile>(); vm.ProfileCollection = db.UserProfiles.ToList(); vm.ProfileCollection.Remove(profile); vm.StatusList = db.Statuses.ToList(); return View(vm); }
// GET: /Profile/ public ActionResult Index() { var currentUser = UserDB.Users.Find(User.Identity.GetUserId()); if (currentUser.MadeProfileYet) { var vm = new ProfileStatus(); vm.StatusList = new List<Status>(); Guid UserId = new Guid(User.Identity.GetUserId()); var profile = db.UserProfiles.FirstOrDefault(x => x.AspNetUser_Id == UserId); vm.Profile = profile; return View(vm); } else return RedirectToAction("CreateProfile"); }