/// <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> /// GetProjectList /// </summary> /// <returns>List<IssueModel></returns> public static List<Project> GetProjectList() { List<Project> projects = new List<Project>(); try { using (var db = new ProjectManagerEntities()) { var query = from p in db.ProjectDALs select p; // get the list of projects. foreach (var q in query) { var proj = new Project ( q.ProjectID, q.Name, DateTime.Parse(q.StartDate.ToString()), DateTime.Parse(q.EndDate.ToString()), q.Status, q.Description, q.ProjectCategoryID.ToString(), DateTime.Parse(q.DueDate.ToString()) ); var issueDals = new IssueDAL(); // get the list of issues for the specific projectID. proj.Issues = issueDals.GetIssueList(proj.ProjectID); // add to the project list projects.Add(proj); } } } catch (Exception) { throw; } return projects; }
/// <summary> /// Create a new IssueDAL object. /// </summary> /// <param name="issueID">Initial value of the IssueID property.</param> /// <param name="subject">Initial value of the Subject property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="projectID">Initial value of the ProjectID property.</param> public static IssueDAL CreateIssueDAL(global::System.Int32 issueID, global::System.String subject, global::System.String description, global::System.Int32 projectID) { IssueDAL issueDAL = new IssueDAL(); issueDAL.IssueID = issueID; issueDAL.Subject = subject; issueDAL.Description = description; issueDAL.ProjectID = projectID; return issueDAL; }
/// <summary> /// Deprecated Method for adding a new object to the IssueDALs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToIssueDALs(IssueDAL issueDAL) { base.AddObject("IssueDALs", issueDAL); }