Пример #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;
            }
        }
Пример #2
0
        /// <summary>
        /// AddIssueAttachment
        /// </summary>
        /// <param name="issueAttachment">IssueAttachment</param>
        /// <returns>bool</returns>
        public static bool AddIssueAttachment(IssueAttachment issueAttachment)
        {
            var returnValue = false;

            try
            {
                using (var db = new ProjectManagerEntities())
                {
                    db.Connection.Open();
                    var ia = new IssueAttachmentDAL();
                    ia.Filename = issueAttachment.FileName;
                    ia.EntryDate = issueAttachment.EntryDate;
                    ia.Description = issueAttachment.Description;
                    ia.IssueID = issueAttachment.IssueID;
                    ia.UserID = issueAttachment.UserID;
                    ia.MimeType = issueAttachment.MimeType;
                    ia.FileData = issueAttachment.FileData;

                    // save issue Attachment.
                    db.IssueAttachmentDALs.AddObject(ia);
                    db.SaveChanges();

                }

                returnValue = true;

            }
            catch (Exception)
            {

                throw;
            }

            return returnValue;
        }
Пример #3
0
        /// <summary>
        /// EditIssue
        /// </summary>
        /// <param name="issue">Issue</param>
        /// <returns>bool</returns>
        public static bool EditIssue(Issue issue)
        {
            try
            {
                var returnValue = false;

                // 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 query = (from i in db.IssueDALs
                                    where i.IssueID == issue.IssueID
                                    select i).First();

                        if (query != null)
                        {
                            query.IssueID = issue.IssueID;
                            query.Subject = issue.Subject;
                            query.ProjectID = issue.ProjectID;
                            query.Priority = issue.CurrentPriority.ToString();
                            query.Status = issue.CurrentStatus.ToString();
                            query.Description = issue.Description;
                            query.IssueCategoryName = issue.IssueCategoryName;
                            query.EntryDate = issue.EntryDate;
                        }

                        // update issue.
                        db.SaveChanges();

                        // get Issue Assignment for this issue.
                        var query2 = (from ia in db.IssueAssignmentDALs
                                     where ia.IssueID == issue.IssueID
                                     select ia).First();

                        if (query2 != null)
                        {
                            query2.IssueID = issue.IssueID;
                            query2.UserID = issue.Assignee.UserId;
                        }

                        // update issue assignment.
                        db.SaveChanges();

                    }

                    transaction.Complete();

                    // successfully inserted.
                    returnValue = true;
                }

                return returnValue;

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

                throw;
            }
        }
Пример #4
0
        /// <summary>
        /// DeleteIssueAttachment
        /// </summary>
        /// <param name="issueAttachmentID">int</param>
        /// <returns>bool</returns>
        public static bool DeleteIssueAttachment(int issueAttachmentID)
        {
            var returnValue = false;
            try
            {
                using (var db = new ProjectManagerEntities())
                {
                    // get the file attachment.
                    var query = (from i in db.IssueAttachmentDALs
                                 where i.IssueAttachmentID == issueAttachmentID
                                 select i).First();

                    if (query != null)
                    {
                        // delete the file attachment.
                        db.DeleteObject(query);
                        db.SaveChanges();
                    }
                }

                returnValue = true;

            }
            catch (Exception)
            {
                throw;
            }
            return returnValue;
        }