public ActionResult Student() { var identity = (ClaimsIdentity)User.Identity; var id = identity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value; var user = userService.Get(int.Parse(id)); List <StudentTaskViewModelPartial> tasks = new List <StudentTaskViewModelPartial>(); foreach (UserTask task in userTaskService.GetAll().Where(x => x.UserID == user.ID)) { tasks.Add(new StudentTaskViewModelPartial { ID = task.ID, Task = taskService.Get(task.TaskID), Answer = task.Answer, Comment = task.Comment, Grade = task.Grade }); } GradeActivityViewModel model = new GradeActivityViewModel() { Grades = gradeService.GetAll().Where(x => x.UserID == user.ID), Activities = activityService.GetAll().Where(x => x.UserID == user.ID), Tasks = tasks }; return(PartialView("_StudentPartial", model)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Task task = taskService.Get(id); if (task == null) { return(HttpNotFound()); } List <UserTask> userTask = userTaskService.GetAll().Where(x => x.TaskID == task.ID).ToList(); AdminTaskViewModel model = new AdminTaskViewModel { ID = task.ID, Description = task.Description, Right = task.Right, Title = task.Title, Section = task.Section, Students = userTaskService.GetAll().Where(x => x.TaskID == task.ID) .Select(x => new AdminInnerTaskModel { Answer = x.Answer, Comment = x.Comment, Grade = x.Grade, User = userService.Get(x.UserID) }) }; return(View(model)); }
public ActionResult Report(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User user = userService.Get(id); if (user == null) { return(HttpNotFound()); } ReportViewModel model = new ReportViewModel() { User = user, Activities = activityService.GetAll().Where(x => x.UserID == id), Grades = gradeService.GetAll().Where(x => x.UserID == id), Tasks = userTaskService.GetAll().Where(x => x.UserID == id) .Select(x => new ExtentionTaskViewModel { ID = x.ID, Answer = x.Answer, Comment = x.Comment, Grade = x.Grade, Task = taskService.Get(x.TaskID), User = userService.Get(x.UserID) }) }; return(View(model)); }
public UserTasksViewModel(IUserTaskService userTaskService) { DisplayAddTaskBoxCommand = new RelayCommand(DisplayAddTaskBox, CanDisplayAddTaskBox); AddUserTaskCommand = new RelayCommand(AddUserTask, CanAddUserTask); _userTaskService = userTaskService; var asyncTask = _userTaskService.GetAll(); asyncTask.Wait(); UserTasks = new ObservableCollection <UserTask>(asyncTask.Result); CurrentUserTask = new UserTask(); }
public async Task <IActionResult> GetAll() { var result = await _userTaskService.GetAll(); if (result == null) { return(NotFound("Collection is empty!")); } var response = _mapper.Map <IEnumerable <UserTaskResponse> >(result); return(Ok(response)); }
public ActionResult Task() { var identity = (ClaimsIdentity)User.Identity; var id = identity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value; var user = userService.Get(int.Parse(id)); List <GroupSection> groupSections = new List <GroupSection>(); if (user.GroupID != null) { groupSections.AddRange(groupSectionService.GetAll().Where(x => x.GroupID == user.GroupID)); } //Section by group List <Section> sections = new List <Section>(); foreach (var item in sectionService.GetAll()) { for (int i = 0; i < groupSections.Count; i++) { if (item.ID == groupSections[i].SectionID) { sections.Add(item); groupSections.Remove(groupSections[i]); } } } List <Task> tasks = new List <Task>(); foreach (var item in sections) { foreach (var task in item.Tasks) { var past = userTaskService.GetAll().Where(x => x.TaskID == task.ID && x.UserID == user.ID) .FirstOrDefault(); if (past == null && task.SectionID == item.ID) { tasks.Add(task); } } } ChooseTaskViewModel model = new ChooseTaskViewModel { DropList = tasks.Select(q => new SelectListItem { Text = q.Title, Value = q.ID.ToString() }).ToList() }; return(View(model)); }
public ActionResult Index() { List <ExtentionTaskViewModel> model = userTaskService.GetAll().Select(x => new ExtentionTaskViewModel { ID = x.ID, Answer = x.Answer, Comment = x.Comment, Grade = x.Grade, Task = taskService.Get(x.TaskID), User = userService.Get(x.UserID) }).ToList(); return(View(model)); }
// GET: Details public async Task <ActionResult> Details(int?id) { if (id == null) { _logger.Error("Error receiving Details() of user. id == null"); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User user = await _userService.Get((int)id); if (user == null) { _logger.Error("Error receiving Details() of user. The task is not found"); return(HttpNotFound()); } var usersTasks = await _userTaskService.GetAll(); usersTasks = usersTasks.Where(u => u.UserId == id); ViewBag.User = user; return(View(usersTasks)); }
public ActionResult Create(ReportTemplateViewModel report) { if (ModelState.IsValid) { string path = System.Web.HttpContext.Current.Server.MapPath("~/Content/Uploads/"); if (System.IO.File.Exists(path + report.ReportLink)) { System.IO.File.Delete(path + report.ReportLink); } var student = userService.Get(report.ID); #region Activity double period = (student.Group.End - student.Group.Start).TotalDays; List <Activity> activities = activityService.GetAll().Where(x => x.User.ID == report.ID).ToList(); int count = activities.Count(); double percent = 0; if (period > 0) { percent = (count / period) * 100; } #endregion #region Test List <Grade> grades = gradeService.GetAll().Where(x => x.UserID == report.ID).ToList(); List <Test> tests = new List <Test>(); foreach (var section in groupSectionService.GetAll().Where(x => x.GroupID == student.GroupID)) { tests.AddRange(testService.GetAll().Where(x => x.SectionID == section.SectionID)); } Dictionary <Test, double> gradesTests = new Dictionary <Test, double>(); foreach (var test in tests) { foreach (var grade in grades) { if (grade.TestID == test.ID) { gradesTests.Add(test, grade.Value); break; } } if (!gradesTests.ContainsKey(test)) { gradesTests.Add(test, 0); } } #endregion #region Task List <UserTask> taskGrades = userTaskService.GetAll().Where(x => x.UserID == report.ID).ToList(); List <Task> tasks = new List <Task>(); foreach (var section in groupSectionService.GetAll().Where(x => x.GroupID == student.GroupID)) { tasks.AddRange(taskService.GetAll().Where(x => x.SectionID == section.SectionID)); } Dictionary <Task, double> gradesTasks = new Dictionary <Task, double>(); foreach (var task in tasks) { foreach (var grade in taskGrades) { if (grade.TaskID == task.ID) { double normalize; switch (grade.Grade) { case "Отлично": normalize = 1; break; case "Хорошо": normalize = 0.75; break; case "Удовлетворительно": normalize = 0.5; break; case "Неудовлетворительно": normalize = 0.25; break; default: normalize = 0; break; } gradesTasks.Add(task, normalize); break; } } if (!gradesTasks.ContainsKey(task)) { gradesTasks.Add(task, 0); } } #endregion Report result = new Report { Link = CreatePDF(student, gradesTests, gradesTasks, percent, report.Review, activities) }; var oldReport = student.Report; student.Report = result; userService.Edit(student); if (oldReport != null && oldReport.ID != 0) { reportService.Delete(oldReport); } return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(userService.GetAll().Where(x => x.Role.Value.Equals("Студент")), "ID", "Surname"); return(View(report)); }
// GET: List public async Task <ActionResult> Index() { return(View(await _userTaskService.GetAll())); }
public List <UserTask> Get() { return(_userTaskService.GetAll()); }