public IActionResult ShowTask(string returnUrl, int StTaskID) { var task = Context.Tasks.FirstOrDefault(x => x.StTaskID == StTaskID); if (task != null) { var answers = Documentation.Answers.Where(x => x.StTaskID == StTaskID); var AnswerViewModels = new List <AnswerViewModel>(); var FileViewModels = new List <StTaskFileData>(); foreach (var item in answers) { var user = Context.Users.FirstOrDefault(x => x.Id == item.UserID); AnswerViewModels.Add(new AnswerViewModel { Answer = item, User = user, IsTeacherAnswer = Context.UserRoles.Any(x => x.UserId == user.Id & Context.Roles.FirstOrDefault(y => x.RoleId == y.Id).Name == "Teacher") }); } foreach (var item in Files.StudentTaskFiles.Where(x => x.StTaskId == task.StTaskID).ToList()) { FileViewModels.Add(new StTaskFileData(item.FileName, item.FileExtansion, item.FileSize, item.Description)); } var model = new ShowTaskViewModel() { returnUrl = returnUrl, Answers = AnswerViewModels.OrderBy(x => x.Answer.AnswerDate).Reverse().ToList(), User = Context.Users.FirstOrDefault(x => x.Id == task.UserID), Task = task, Files = FileViewModels }; return(View(model)); } return(LocalRedirect(returnUrl)); }
public ActionResult ShowTask(int id) { var assignment = _context.Assignments.SingleOrDefault(c => c.Id == id); assignment.Team = _context.Teams.SingleOrDefault(c => c.Id == assignment.TeamId); assignment.UserResponsabil = _context.Users.SingleOrDefault(c => c.Id == assignment.UserResponsabilId); var userId = _context.Projects.SingleOrDefault(c => c.Id == assignment.Team.ProjectId).UserId; var viewModel = new ShowTaskViewModel { Assignment = assignment }; viewModel.EsteAdmin = User.IsInRole("Administrator"); viewModel.AfisareButoane = false; viewModel.AfisareModifica = false; var userIdCurrent = User.Identity.GetUserId(); if (userIdCurrent == assignment.UserResponsabilId) { viewModel.AfisareModifica = true; } if (userId == userIdCurrent || User.IsInRole("Administrator")) { viewModel.AfisareButoane = true; } return(View("Show", viewModel)); }
public ShowTaskPage(Models.Task model, BaseViewModel parent) { InitializeComponent(); var viewModel = new ShowTaskViewModel(this, model); viewModel.Parent = parent; BindingContext = viewModel; }
public ShowTaskWindow(TaskModel task, UserModel user, ColumnModel column, BoardModel board, BoardModel backupBoard) { InitializeComponent(); StVM = new ShowTaskViewModel(task, column); this.DataContext = StVM; this.task = task; this.column = column; this.user = user; this.board = board; this.backupBoard = backupBoard; }
public async Task <IActionResult> ShowTask(string returnUrl, int StTaskID) { var task = Docs.Tasks.FirstOrDefault(x => x.StTaskID == StTaskID); if (task != null) { var StUser = await Manager.FindByNameAsync(User.Identity.Name); if (task.UserID != StUser.Id) { return(LocalRedirect(returnUrl)); } var answers = Docs.Answers.Where(x => x.StTaskID == StTaskID); var AnswerViewModels = new List <AnswerViewModel>(); var FileViewModels = new List <StTaskFileData>(); foreach (var item in answers) { var user = await Manager.FindByIdAsync(item.UserID); AnswerViewModels.Add(new AnswerViewModel { Answer = item, User = user, IsTeacherAnswer = StUser.Id == user.Id ? false : true }); } foreach (var item in Files.StudentTaskFiles.Where(x => x.StTaskId == task.StTaskID).ToList()) { FileViewModels.Add(new StTaskFileData(item.FileName, item.FileExtansion, item.FileSize, item.Description)); } var model = new ShowTaskViewModel() { returnUrl = returnUrl, Answers = AnswerViewModels.OrderBy(x => x.Answer.AnswerDate).Reverse().ToList(), User = StUser, Task = task, Files = FileViewModels }; return(View(model)); } return(LocalRedirect(returnUrl)); }