/// <summary> /// Save support tickets /// </summary> /// <param name="creationDate">creationDate</param> /// <param name="companyId">companyId</param> public int? Save(DateTime creationDate, int companyId) { int newSupportTicketId = 0; SupportTicketAddTDS supportTicketAddChanges = (SupportTicketAddTDS)Data.GetChanges(); if (supportTicketAddChanges.BasicInformation.Rows.Count > 0) { foreach (SupportTicketAddTDS.BasicInformationRow row in (SupportTicketAddTDS.BasicInformationDataTable)supportTicketAddChanges.BasicInformation) { int categoryId = row.CategoryID; string subject = ""; if (!row.IsSubjectNull()) subject = row.Subject; string comment = ""; if (!row.IsCommentNull()) comment = row.Comment; DateTime? dueDate = null; if (!row.IsDueDateNull()) dueDate = row.DueDate; int employeeId = 0; if (!row.IsTeamMemberIDNull()) employeeId = row.TeamMemberID; bool deleted = row.Deleted; string state = row.State; int createdById = row.CreatedByID; int refId = 1; string type_ = row.Type_; // ... Insert the support ticket SupportTicketSupportTicket supportTicketSupportTicket = new SupportTicketSupportTicket(null); newSupportTicketId = supportTicketSupportTicket.InsertDirect(categoryId, subject, creationDate, createdById, state, dueDate, deleted, companyId); // ... Insert first Activity (Default Assignation - first Activity) SupportTicketSupportTicketActivity supportTicketSupportTicketActivity = new SupportTicketSupportTicketActivity(null); supportTicketSupportTicketActivity.InsertDirect(newSupportTicketId, refId, type_, creationDate, employeeId, comment, row.Deleted, companyId); } } return newSupportTicketId; }
/// <summary> /// Save /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { SupportTicketInformationTDS toDoListInformationChanges = (SupportTicketInformationTDS)Data.GetChanges(); if (toDoListInformationChanges != null) { if (toDoListInformationChanges.BasicInformation.Rows.Count > 0) { SupportTicketInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new SupportTicketInformationBasicInformationGateway(toDoListInformationChanges); // Update to do foreach (SupportTicketInformationTDS.BasicInformationRow row in (SupportTicketInformationTDS.BasicInformationDataTable)toDoListInformationChanges.BasicInformation) { // Unchanged values int supportTicketId = row.SupportTicketID; int categoryId = row.CategoryID; string subject = toDoListInformationBasicInformationGateway.GetSubject(supportTicketId); DateTime creationDate = toDoListInformationBasicInformationGateway.GetCreationDate(supportTicketId); int createdById = toDoListInformationBasicInformationGateway.GetCreatedByID(supportTicketId); // Original values DateTime? originalDueDate = null; if (toDoListInformationBasicInformationGateway.GetDueDateOriginal(supportTicketId).HasValue) originalDueDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDateOriginal(supportTicketId); string originalState = toDoListInformationBasicInformationGateway.GetStateOriginal(supportTicketId); // New variables DateTime? newDueDate = null; if (toDoListInformationBasicInformationGateway.GetDueDate(supportTicketId).HasValue) newDueDate = (DateTime)toDoListInformationBasicInformationGateway.GetDueDate(supportTicketId); string newState = toDoListInformationBasicInformationGateway.GetState(supportTicketId); SupportTicketSupportTicket toDoListSupportTicket = new SupportTicketSupportTicket(null); toDoListSupportTicket.UpdateDirect(supportTicketId, categoryId, subject, creationDate, createdById, originalState, originalDueDate, row.Deleted, row.COMPANY_ID, supportTicketId, categoryId, subject, creationDate, createdById, newState, newDueDate, row.Deleted, row.COMPANY_ID); } } } }