public async Task <IActionResult> GetAssignment(int assignmentId) { var assignment = await _assignmentService.GetAssignment(assignmentId); var plan = await _planService.GetPlan(assignment.PlanId, User.UserId()); var patrols = await _patrolRepository.GetPatrolsForUser(User.UserId()); var user = (UserIdentifier)await _userRepository.GetUser(assignment.UserId); if (User.PatrolIds().Any(x => x == plan.PatrolId)) { return(Ok( new { User = user, Plan = plan, Assignment = assignment })); } else { return(Forbid()); } }
protected override BaseResponse <AssignmentViewModel> ExecuteCore(AssignmentInfoRequestViewModel request) { var assignment = assignmentService.GetAssignment(request.AssignmentId); if (assignment is null) { return(GetResponseFailed(Resources.Errors_AssignmentDoesNotExist)); } var validationResult = ValidateProjectAccess(projectService, assignment.Epic.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } var assignmentViewModel = new AssignmentViewModel { Id = assignment.Id, Name = assignment.Name, Status = assignment.Status, Deadline = assignment.Deadline, Description = assignment.Description, AssigneeId = assignment.Assignee?.Id.ToString(), CreatedOn = assignment.CreatedOn, AuthorFirstName = assignment.CreatedBy.FirstName, AuthorLastName = assignment.CreatedBy.LastName, ModifiedOn = assignment.ModifiedOn, LastModifiedFirstName = assignment.ModifiedBy?.FirstName, LastModifiedLastName = assignment.ModifiedBy?.LastName }; return(GetResponseSuccess(assignmentViewModel)); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(PostCommentRequestViewModel request) { var assignment = assignmentService.GetAssignment(request.AssignmentId); if (assignment is null) { return(GetResponseFailed(Resources.Errors_AssignmentDoesNotExist)); } var validationResult = ValidateProjectAccess(projectService, assignment.Epic.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } var comment = new Comment { Assignment = assignment, CreatedBy = CurrentApplicationUser, CreatedOn = DateTime.UtcNow, Content = request.Content, }; repository.Add(comment); if (assignment.Assignee != null) { notificationService.CreateNewCommentNotification(CurrentApplicationUser, assignment.Assignee, assignment); } repository.SaveChanges(); return(GetGenericResponseSuccess(null).WithStatusCode(ResponseStatusCodes.Created)); }
public async Task <IActionResult> GetAssignment(int assignmentId) { ServiceResponse <GetAssignmentDto> response = await _assignmentService.GetAssignment(assignmentId); if (response.Success) { return(Ok(response)); } return(NotFound(response)); }
public IActionResult GetAssignment(string json) { try { dynamic jsonString = _assignmentService.GetAssignment(json); return(Ok(jsonString)); } catch (Exception e) { throw e; } }
public async Task <IActionResult> AddToUser(string userId, string assignmentId) { User user = await _userManager.FindByIdAsync(userId); AssignmentDTO assignment = _Assignment.GetAssignment(assignmentId); if (user == null) { return(NotFound()); } if (assignment == null) { return(NotFound()); } _UserAssignment.AddUserAssignment(assignment, user); /*string hostemail = _configuration.GetValue<string>("MySettings:Email"); * string hosppassword = _configuration.GetValue<string>("MySettings:Password"); * int port = _configuration.GetValue<int>("MySettings:SMTPPort"); * EmailService emailService = new EmailService(); * await emailService.SendEmailAsync(user.Email, "You resieved a new assignment XD", * $"We granted you a new assignment =) {assignment.Name}, please check it", hostemail, hosppassword, port);*/ return(RedirectToAction("Index", "Users", userId)); }
public async Task <IActionResult> DownloadAsync(Guid AssignId) { //1. get who is the owner of the file with id = id //2. you fetch the private key //3. call the HybridDecrypt var assignment = _assignmentService.GetAssignment(AssignId); var webClient = new System.Net.WebClient(); string absolutePath = _env.WebRootPath + @"\Files\" + assignment.Path; var downData = webClient.DownloadData(absolutePath); var sign = await _userManager.FindByNameAsync(User.Identity.Name); MemoryStream toDownload = new MemoryStream(downData); MemoryStream other = new MemoryStream(Encoding.UTF32.GetBytes(assignment.FileName));// = HybridDecrypt(...) other.Position = 0; //encrypt upload decrypt down //-->bool = false //return File(toDownload, "application/octet-stream", Guid.NewGuid() + "-" + fileDownloadName); if (Encryption.VerifyData(toDownload, sign.PublicKey, assignment.Signature)) { var fileDownloadName = assignment.FileName + ".pdf"; var ip = HttpContext.Connection.RemoteIpAddress; _logger.LogInformation("-->" + User.Identity.Name + " has successfully downloaded a file from this Ip address " + ip); return(File(toDownload, "application/octet-stream", Guid.NewGuid() + "-" + fileDownloadName)); } else { TempData["error"] = "File could not be downloaded!"; return(View()); } /* * MemoryStream toDownload = new MemoryStream(Encoding.UTF32.GetBytes(fileName)); * toDownload.Position = 0; * * bool result = Encryption.VerifyData(msIn2, sign.PublicKey, signature); * */ }
protected override BaseResponse <IList <CommentDto> > ExecuteCore(AssignmentInfoRequestViewModel request) { var assignment = assignmentService.GetAssignment(request.AssignmentId); if (assignment is null) { return(GetResponseFailed(Resources.Errors_AssignmentDoesNotExist)); } var validationResult = ValidateProjectAccess(projectService, assignment.Epic.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } var comments = repository.Comments .ReadNotDeleted(x => x.Assignment == assignment) .Include(x => x.CreatedBy) .Include(x => x.Assignment) .ThenInclude(x => x.Assignee) .OrderByDescending(x => x.CreatedOn) .Select(x => new CommentDto { Id = x.Id, CreatedOn = x.CreatedOn, Content = x.Content, AssignmentId = x.Assignment.Id, IsAssignee = x.CreatedBy == x.Assignment.Assignee, AuthorId = x.CreatedBy.Id, AuthorName = string.Join(' ', x.CreatedBy.FirstName, x.CreatedBy.LastName), IsAuthor = x.CreatedBy == CurrentApplicationUser }) .ToList(); return(GetResponseSuccess(comments)); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(UpdateAssignmentStatusRequestViewModel request) { var assignment = assignmentService.GetAssignment(request.AssignmentId); if (assignment is null) { return(GetResponseFailed(Resources.Errors_AssignmentDoesNotExist)); } var validationResult = ValidateProjectAccess(projectService, assignment.Epic.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } assignment.Status = request.Status; repository.Update(assignment, CurrentApplicationUser); repository.SaveChanges(); return(GetResponseSuccess()); }
public async Task <AssignmentDto> GetAssignment(Guid invoiceId) { return(await _assignmentService.GetAssignment(invoiceId)); }
public async Task <IHttpActionResult> GetAssignment(int AssignmentID) { AssignmentModel assignment = (await _AssignmentService.GetAssignment(AssignmentID)); return(Json(assignment)); }
public AssignmentModel Get(int id) { return(assignmentService.GetAssignment(id)); }