Ejemplo n.º 1
0
    public static void GenerateDemoData(
      IIssueRepository issueRepository, 
      IProjectRepository projectRepository, 
      IAttachmentRepository attachmentRepository)
    {
      Project p = new Project("SHOP", "Webshop", "All issues related to the webshop.");
      projectRepository.Add(p);

      Issue i = new Issue(p, "Crash after payment", @"I have justed paid for two pairs of shoes - or rather I tried to. When I clicked 'Pay' all I got was a yellow error screen.", 3);

      issueRepository.Add(i);

      string errorReport = "This is an error report ...";
      Attachment att = new Attachment(i, "Error report", "Error report from end user", Encoding.UTF8.GetBytes(errorReport), "text/plain");
      attachmentRepository.Add(att);

      string logFile = "DEBUG 2014-01-22 15:45:07,610 166033ms  [9] Log4NetTraceListener   WriteLine          - Executing OperationResult OperationResult: type=OK, statusCode=200.";
      att = new Attachment(i, "Logfile", "Logfile with server stack trace", Encoding.UTF8.GetBytes(logFile), "text/plain");
      attachmentRepository.Add(att);

      i = new Issue(p, "Not calculating VAT correctly", @"When I add both shoes and socks it fails to calculate the VAT correctly.", 3);

      issueRepository.Add(i);

      i = new Issue(p, "General Failure?", @"When I press ctrl-P it says 'General failure reading harddisk'! Who is that General and why is he reading my hard disk?", 5);

      issueRepository.Add(i);
    }
Ejemplo n.º 2
0
 public Attachment(Issue owner, string title, string description, byte[] content, string contentType)
 {
   Condition.Requires(owner, "owner").IsNotNull();
   OwnerIssue = owner;
   Update(title, description, content, contentType);
   CreatedDate = DateTime.Now;
 }
Ejemplo n.º 3
0
    // "id" is project ID
    public object Post(int id, AddIssueArgs args, IFile attachment = null)
    {
      return ExecuteInUnitOfWork(() =>
      {
        Project p = ProjectRepository.Get(id);

        Issue i = new Issue(p, args.Title, args.Description, args.Severity);
        IssueRepository.Add(i);

        if (args.Attachment != null && attachment != null)
        {
          using (Stream s = attachment.OpenStream())
          {
            byte[] content = s.ReadAllBytes();
            Attachment att = new Attachment(i, args.Attachment.Title, args.Attachment.Description, content, attachment.ContentType.MediaType);
            AttachmentRepository.Add(att);
          }
        }

        Uri issueUrl = typeof(IssueResource).CreateUri(new { id = i.Id });

        return new OperationResult.Created { RedirectLocation = issueUrl };
      });
    }