コード例 #1
0
ファイル: IssueDAL.cs プロジェクト: benhejl/SWENG500_Team1
        /// <summary>
        /// AddIssue - Add New Issue
        /// </summary>
        /// <param name="issue">Issue</param>
        /// <returns>bool</returns>
        public static bool AddIssue(Issue issue)
        {
            try
            {
                var returnValue = false;
                var id = 0;

                // wrap in a TransactionScope since we are updating two tables - Issues and IssueAssignments
                using (TransactionScope transaction = new TransactionScope())
                {

                    using (var db = new ProjectManagerEntities())
                    {

                            db.Connection.Open();
                            var i = new IssueDAL();
                            //i.IssueID = -1;
                            i.Subject = issue.Subject;
                            i.ProjectID = issue.ProjectID;
                            i.Priority = issue.CurrentPriority.ToString();
                            i.Status = issue.CurrentStatus.ToString();
                            i.Description = issue.Description;
                            i.IssueCategoryName = issue.IssueCategoryName;
                            i.EntryDate = issue.EntryDate;

                            // save issue.
                            db.IssueDALs.AddObject(i);
                            db.SaveChanges();

                            // get the newly inserted issueid.
                            id = i.IssueID;

                            // save issue assignment.
                            var issueAssignment = new IssueAssignmentDAL();
                            issueAssignment.IssueID = id;
                            issueAssignment.UserID = issue.Assignee.UserId;
                            db.IssueAssignmentDALs.AddObject(issueAssignment);
                            db.SaveChanges();

                        }

                        transaction.Complete();

                        // successfully inserted.
                        returnValue = true;
                }

                return returnValue;

            }
            catch (TransactionAbortedException)
            {
                throw;
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #2
0
 /// <summary>
 /// Create a new IssueAssignmentDAL object.
 /// </summary>
 /// <param name="issueAssignmentID">Initial value of the IssueAssignmentID property.</param>
 /// <param name="issueID">Initial value of the IssueID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 public static IssueAssignmentDAL CreateIssueAssignmentDAL(global::System.Int32 issueAssignmentID, global::System.Int32 issueID, global::System.Int32 userID)
 {
     IssueAssignmentDAL issueAssignmentDAL = new IssueAssignmentDAL();
     issueAssignmentDAL.IssueAssignmentID = issueAssignmentID;
     issueAssignmentDAL.IssueID = issueID;
     issueAssignmentDAL.UserID = userID;
     return issueAssignmentDAL;
 }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the IssueAssignmentDALs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIssueAssignmentDALs(IssueAssignmentDAL issueAssignmentDAL)
 {
     base.AddObject("IssueAssignmentDALs", issueAssignmentDAL);
 }