Пример #1
0
        /// <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;
            }
        }
 /// <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;
 }
 /// <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);
 }