<ul id="myTab" class="nav nav-tabs"> @{ var group = Model.GroupBy(g => g.ReviewID).ToList(); } @foreach (var item in group) { string active = @group.First() == item ? "active" : string.Empty; <li class="@active"><a href="#@Model.Where(a => a.ReviewID == item.Key).Single().Review.PersonID" data-toggle="tab"></a></li> } <li class="form-group pull-right"> <div class="col-md-offset-1 col-md-12"> <input type="submit" value="Submit" class="btn btn-primary btn-default" name="Add" /> </div> </li> </ul>
public ActionResult Index() { DateTime dateToday = DateTime.Now; DateTime firstOfThisMonth = new DateTime(dateToday.Year, dateToday.Month, 1); string name = User.Identity.Name; string newName = GetUserName(name); var unansweredReviews = from ur in db.Reviews where ur.PersonID == newName where ur.Responses.Any(s => s.ScoreID == null) select ur; if(unansweredReviews.Any()) { return View(unansweredReviews.SelectMany(u => u.Responses).ToList()); } var reviewForCurrentMonth = from cm in db.Reviews where cm.PersonID == newName where cm.DateTimeReviewed != null && cm.DateTimeReviewed <= firstOfThisMonth select cm; if(reviewForCurrentMonth.Any()) { Response.Redirect("~/Home/Index"); } else { var getQuestions = db.Questions.Select(q => q.QuestionID); var peersToReview = db.People.Where(p => p.PersonID == newName).Single().MemberGroups.SelectMany(rg => rg.Members).ToList(); foreach (var peers in peersToReview) { Review reviews = new Review(); reviews.PersonID = newName; reviews.ReviewPersonID = peers.PersonID; foreach (var id in getQuestions) { Response responses = new Response(); responses.Review = reviews; responses.QuestionID = id; db.Responses.Add(responses); } db.Reviews.Add(reviews); } db.SaveChanges(); } return View(); }
Model.Where(a => a.ReviewID == item.Key).Single().Review.PersonID
Single()
First()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)