public ActionResult Index(string userName) { UsersUOW userUOF = new UsersUOW(); if (userName != null) { var user = userUOF.FindUser(userName); var categories = _dbContext.UserCategories.ToList(); foreach (var category in categories) { foreach (var categoryUser in category.Users) { if (categoryUser.UserName == user.UserName) { var userCategories = categoryUser.UserCategories; var categoryQuestions = category.Questions; return View(categoryQuestions.ToList()); } } } //user.Id } var questions = _dbContext.Questions.ToList(); return View(questions.ToList()); }
public ActionResult Index(string userName) { UsersUOW userUOF = new UsersUOW(); if (userName != null) { var user = userUOF.FindUser(userName); var questions = _dbContext.Questions.Where(q => q.UserId == user.Id); return PartialView("_Index", questions.ToList()); } var questionsList = _dbContext.Questions.ToList(); return View(questionsList.ToList()); }
public ActionResult Create() { UsersUOW userUOF = new UsersUOW(); var blogs = _dbContext.Blogs.ToList(); BlogViewModel blogViewModel = new BlogViewModel(); var user = userUOF.FindUser(User.Identity.Name); blogViewModel.TagsList = _dbContext.Tags.ToList().Select(r => new SelectListItem { Selected = false, Text = r.Name, Value = r.Name }); blogViewModel.UserId = user.Id; return View(blogViewModel); }
public ActionResult CreateNewStyleBlog() { UsersUOW userUOF = new UsersUOW(); var blogs = _dbContext.Blogs.ToList(); BlogViewModel blogViewModel = new BlogViewModel(); var user = userUOF.FindUser(User.Identity.Name); blogViewModel.Tags = _dbContext.Tags.Select(tag => new TagsCheckBox { Id = tag.Id, Name = tag.Name, IsChecked = false }).ToList(); blogViewModel.UserId = user.Id; return View(blogViewModel); }
public ActionResult Create(UserProfile userProfile) { if (ModelState.IsValid) { UsersUOW userUOF = new UsersUOW(); var user = userUOF.FindUser(User.Identity.Name); userProfile.Id = Guid.NewGuid(); userProfile.UserId = user.Id; _dbContext.UserProfiles.Add(userProfile); _dbContext.SaveChanges(); return RedirectToAction("Index", "Home"); } return View(userProfile); }
public ActionResult Edit(string userName) { if (userName == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } UsersUOW userUOF = new UsersUOW(); var user = userUOF.FindUser(userName); UserProfile userProfile = _dbContext.UserProfiles.Where(u => u.UserId == user.Id).FirstOrDefault(); UserProfileViewModel viewModel = Mapper.Map<UserProfileViewModel>(userProfile); if (userProfile == null) { return RedirectToAction("Create", "UserProfiles"); } if (user != null) { var questions = _dbContext.Questions.Where(u => u.UserId == user.Id).ToList(); viewModel.Questions = questions; } return View(viewModel); }
public ActionResult Edit(Guid? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Blog blog = _dbContext.Blogs.Find(id); if (blog == null) { return HttpNotFound(); } UsersUOW userUOF = new UsersUOW(); BlogViewModel blogViewModel = Mapper.Map<BlogViewModel>(blog); var user = userUOF.FindUser(User.Identity.Name); var tags = _dbContext.Tags; blogViewModel.MainImageName = blog.MainImageName; blogViewModel.TagsList = tags.ToList().Select(r => new SelectListItem { Selected = blog.Tags.Contains(r), Text = r.Name, Value = r.Name }); blogViewModel.UserId = user.Id; return View(blogViewModel); }