예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the IssueAttachments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIssueAttachments(IssueAttachment issueAttachment)
 {
     base.AddObject("IssueAttachments", issueAttachment);
 }
예제 #2
0
 /// <summary>
 /// Create a new IssueAttachment object.
 /// </summary>
 /// <param name="issueAttachmentID">Initial value of the IssueAttachmentID property.</param>
 /// <param name="filename">Initial value of the Filename property.</param>
 /// <param name="entryDate">Initial value of the EntryDate property.</param>
 /// <param name="developerID">Initial value of the DeveloperID property.</param>
 /// <param name="issueID">Initial value of the IssueID property.</param>
 /// <param name="mimeType">Initial value of the MimeType property.</param>
 public static IssueAttachment CreateIssueAttachment(global::System.Int32 issueAttachmentID, global::System.String filename, global::System.DateTime entryDate, global::System.Int32 developerID, global::System.Int32 issueID, global::System.String mimeType)
 {
     IssueAttachment issueAttachment = new IssueAttachment();
     issueAttachment.IssueAttachmentID = issueAttachmentID;
     issueAttachment.Filename = filename;
     issueAttachment.EntryDate = entryDate;
     issueAttachment.DeveloperID = developerID;
     issueAttachment.IssueID = issueID;
     issueAttachment.MimeType = mimeType;
     return issueAttachment;
 }
        public ActionResult Create(string Subject, string Priority, string Severity, string Status,
            string Description, string IssueCategoryName, int? MilestoneID, int ProjectID, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
                return View();

            try
            {
                Issue issue = new Issue();
                issue.Subject = Subject;
                issue.Priority = Priority;
                issue.Severity = Severity;
                issue.Status = Status;
                issue.Description = Description;
                issue.EntryDate = DateTime.Now;
                issue.IssueCategoryName = IssueCategoryName;
                issue.MilestoneID = MilestoneID;
                issue.ProjectID = ProjectID;
                _dataModel.AddToIssues(issue);
                _dataModel.SaveChanges();

                //Save file to server if user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    IssueAttachment issueAttchmnt = new IssueAttachment();
                    issueAttchmnt.Filename = Path.GetFileName(file.FileName);
                    issueAttchmnt.MimeType = file.ContentType;
                    var path = Path.Combine(basePath, issueAttchmnt.Filename);
                    file.SaveAs(path);
                    issueAttchmnt.DeveloperID = _dataModel.Developers.Single(d => d.UserName == User.Identity.Name).DeveloperID;
                    issueAttchmnt.EntryDate = DateTime.Now;
                    issueAttchmnt.IssueID = issue.IssueID;
                    _dataModel.AddToIssueAttachments(issueAttchmnt);
                    _dataModel.SaveChanges();
                }
                return RedirectToAction("Index");
            }
            catch
            {
                return RedirectToAction("Index");
            }
        }