TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vidhya
NA
324
88.3k
how to call testname from repository to service
Aug 5 2013 6:22 AM
Controller
public ActionResult Index(Guid id)
{
return View(_service.IndexBuildView(id));
}
Repository
public List<StudentGradeBook> GetStudentsGradeBook(Guid courseSectionId)
{
int roler = (int)CourseSectionRoster.CourseRoleTypes.Student;
List<StudentGradeBook> lsgb = new List<StudentGradeBook>();
var result = from p in _context.Person2
join cs in _context.CourseSectionRoster on p.PersonId equals cs.PersonId
join a in _context.Assignments on cs.CourseSectionId equals a.CourseSectionId
join asg in _context.AssignmentSubmission on a.AssignmentId equals asg.AssignmentId into asgn
from agn in asgn.DefaultIfEmpty()
where a.GradeBook == true && cs.CourseSectionId == courseSectionId && cs.CourseRole == roler
select new { p.FirstName, p.LastName, a.AssignmentName, a.MakeAvailable, a.PointsPossible, a.DueDateTime, agn.PointsAwarded ,agn.SubmissionDateTime};
var testresult = from t in _context.Test
where t.GradeBook == true && t.CourseSectionId == courseSectionId
select new { t.TestName,t.TotalPoints};
foreach (var item in result)
{
StudentGradeBook sgb = new StudentGradeBook()
{
FirstName = item.FirstName,
LastName = item.LastName,
AssignmentName = item.AssignmentName,
PointsPossible = item.PointsPossible,
DueDateTime = Convert.ToDateTime(item.DueDateTime),
PointsAwarded = item.PointsAwarded,
SubmissionDateTime =item .SubmissionDateTime ,
};
lsgb.Add(sgb);
}
foreach (var titem in testresult)
{
StudentGradeBook tsgb = new StudentGradeBook()
{
TestName = titem.TestName,
TotalPoints = titem.TotalPoints
};
lsgb.Add(tsgb);
}
return lsgb.ToList();
}
Service
public IndexModel IndexBuildView(Guid courseSectionId)
{
CourseSection cs = _courseSectionRepo.GetSectionById(courseSectionId);
IndexModel outer = new IndexModel { CourseSectionId = courseSectionId, CourseName = cs.Course.CourseTitle, SectionNumber = cs.SectionNumber, };
var res = from asg in _gradebookRepo.GetStudentsGradeBook(courseSectionId) select new StudentGradeBook { FirstName = asg.FirstName, LastName = asg.LastName, AssignmentName = asg.AssignmentName, PointsPossible = asg.PointsPossible, DueDateTime = (DateTime)asg.DueDateTime, PointsAwarded = asg.PointsAwarded, SubmissionDateTime = asg.SubmissionDateTime };
here how do i call the testname and totalpoints
outer.Student = res.ToList();
return outer;
}
Model
public class StudentGradeBook
{
public Guid PersonId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Guid CourseSectionRosterId { get; set; }
public int? PointsAwarded { get; set; }
public DateTime? SubmissionDateTime { get; set; }
public int CourseRole { get; set; }
public string AssignmentName { get; set; }
public int PointsPossible { get; set; }
public DateTime DueDateTime { get; set; }
public string TestName { get; set; }
public int TotalPoints { get; set; }
}
Reply
Answers (
0
)
c#.net
links for asp.net & web development begginer