public ActionResult DeleteConfirmed(int id) { KnowledgeBaseCategory knowledgebasecategory = db.KnowledgeBaseCategory.Find(id); db.KnowledgeBaseCategory.Remove(knowledgebasecategory); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /KnowledgeBaseCategory/Create public ActionResult Create() { KnowledgeBaseCategory knowledgebasecategory = new KnowledgeBaseCategory() { UserName = User.Identity.Name }; return(View(knowledgebasecategory)); }
public ActionResult Edit(KnowledgeBaseCategory knowledgebasecategory) { if (ModelState.IsValid) { db.Entry(knowledgebasecategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(knowledgebasecategory)); }
// // GET: /KnowledgeBaseCategory/Edit/5 public ActionResult Edit(int id = 0) { KnowledgeBaseCategory knowledgebasecategory = db.KnowledgeBaseCategory.Find(id); if (knowledgebasecategory == null) { return(HttpNotFound()); } return(View(knowledgebasecategory)); }
public ActionResult Create(KnowledgeBaseCategory knowledgebasecategory) { if (ModelState.IsValid) { db.KnowledgeBaseCategory.Add(knowledgebasecategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(knowledgebasecategory)); }
private void RecoverTickets(int orgID, LoginUser loginUser) { Tickets badTickets = new Tickets(GetCorrupteLoginUser()); SqlCommand command = new SqlCommand(); command.CommandText = @" SELECT * FROM Tickets WHERE OrganizationID = @OrganizationID AND DateCreated > '2015-09-17 05:56:00' AND TicketSource != 'EMail' AND IgnoreMe = 0 "; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@OrganizationID", orgID); badTickets.Fill(command, ""); Organizations existingCompanies = new Organizations(loginUser); existingCompanies.LoadByParentID(orgID, false); foreach (Ticket badTicket in badTickets) { try { //Copy Ticket Ticket goodTicket = (new Tickets(loginUser)).AddNewTicket(); goodTicket.CopyRowData(badTicket); //Product if (badTicket.ProductID != null) { Product goodProduct = _goodProducts.FindByProductID((int)badTicket.ProductID); if (goodProduct == null) { Product badProduct = _badProducts.FindByProductID((int)badTicket.ProductID); goodProduct = _goodProducts.FindByName(badProduct.Name); if (goodProduct != null) { goodTicket.ProductID = goodProduct.ProductID; } else { goodTicket.ProductID = null; } } } //Version if (goodTicket.ProductID != null && badTicket.ReportedVersionID != null) { ProductVersion goodProductVersion = _goodProductVersions.FindByProductVersionID((int)badTicket.ReportedVersionID); if (goodProductVersion == null) { ProductVersion badProductVersion = _badProductVersions.FindByProductVersionID((int)badTicket.ReportedVersionID); goodProductVersion = _goodProductVersions.FindByVersionNumber(badProductVersion.VersionNumber, (int)goodTicket.ProductID); if (goodProductVersion != null) { goodTicket.ReportedVersionID = goodProductVersion.ProductVersionID; } else { goodTicket.ReportedVersionID = null; } } } //Solved Version if (goodTicket.ProductID != null && badTicket.SolvedVersionID != null) { ProductVersion goodProductVersion = _goodProductVersions.FindByProductVersionID((int)badTicket.SolvedVersionID); if (goodProductVersion == null) { ProductVersion badProductVersion = _badProductVersions.FindByProductVersionID((int)badTicket.SolvedVersionID); goodProductVersion = _goodProductVersions.FindByVersionNumber(badProductVersion.VersionNumber, (int)goodTicket.ProductID); if (goodProductVersion != null) { goodTicket.SolvedVersionID = goodProductVersion.ProductVersionID; } else { goodTicket.SolvedVersionID = null; } } } //Group if (badTicket.GroupID != null) { Group goodGroup = _goodGroups.FindByGroupID((int)badTicket.GroupID); if (goodGroup == null) { Group badGroup = _badGroups.FindByGroupID((int)badTicket.GroupID); goodGroup = _goodGroups.FindByName(badGroup.Name); if (goodGroup != null) { goodTicket.GroupID = goodGroup.GroupID; } else { goodTicket.GroupID = null; } } } //Assigned User if (badTicket.UserID != null) { User goodUser = _goodUsers.FindByUserID((int)badTicket.UserID); if (goodUser == null) { User badUser = _badUsers.FindByUserID((int)badTicket.UserID); goodUser = _goodUsers.FindByEmail(badUser.Email); if (goodUser != null) { goodTicket.UserID = goodUser.UserID; } else { goodTicket.UserID = null; } } } //Type TicketType goodTicketType = _goodTicketTypes.FindByTicketTypeID(badTicket.TicketTypeID); if (goodTicketType == null) { TicketType badTicketType = _badTicketTypes.FindByTicketTypeID(badTicket.TicketTypeID); goodTicketType = _goodTicketTypes.FindByName(badTicketType.Name); if (goodTicketType != null) { goodTicket.TicketTypeID = goodTicketType.TicketTypeID; } else { goodTicket.TicketTypeID = _goodTicketTypes[0].TicketTypeID; } } //Status TicketStatus goodTicketStatus = _goodTicketStatuses.FindByTicketStatusID(badTicket.TicketStatusID); if (goodTicketStatus == null) { TicketStatus badTicketStatus = _badTicketStatuses.FindByTicketStatusID(badTicket.TicketStatusID); goodTicketStatus = _goodTicketStatuses.FindByName(badTicketStatus.Name, goodTicket.TicketTypeID); if (goodTicketStatus != null) { goodTicket.TicketStatusID = goodTicketStatus.TicketStatusID; } else { goodTicketStatus = _goodTicketStatuses.FindTopOne(goodTicket.TicketTypeID); goodTicket.TicketStatusID = goodTicketStatus.TicketStatusID; } } //Severity TicketSeverity goodTicketSeverity = _goodTicketSeverities.FindByTicketSeverityID(badTicket.TicketSeverityID); if (goodTicketSeverity == null) { TicketSeverity badTicketSeverity = _badTicketSeverities.FindByTicketSeverityID(badTicket.TicketSeverityID); goodTicketSeverity = _goodTicketSeverities.FindByName(badTicketSeverity.Name); if (goodTicketSeverity != null) { goodTicket.TicketSeverityID = goodTicketSeverity.TicketSeverityID; } else { goodTicket.TicketSeverityID = _goodTicketSeverities[0].TicketSeverityID; } } //Knowledgebase Cat if (badTicket.KnowledgeBaseCategoryID != null) { KnowledgeBaseCategory goodKBCategory = _goodTicketKBCategories.FindByCategoryID((int)badTicket.KnowledgeBaseCategoryID); if (goodKBCategory == null) { KnowledgeBaseCategory badKBCategory = _badTicketKBCategories.FindByCategoryID((int)badTicket.KnowledgeBaseCategoryID); goodKBCategory = _goodTicketKBCategories.FindByName(badKBCategory.CategoryName); if (goodKBCategory != null) { goodTicket.KnowledgeBaseCategoryID = goodKBCategory.CategoryID; } else { goodTicket.KnowledgeBaseCategoryID = null; } } } //Parent Ticket (NOTE from MT: we decided as a team to null out this field to ensure no bad relationships can happen since we don't know the ticketID is a preserved field for every ticket. goodTicket.ParentID = null; //Closing User if (badTicket.CloserID != null) { User goodUser = _goodUsers.FindByUserID((int)badTicket.CloserID); if (goodUser == null) { User badUser = _badUsers.FindByUserID((int)badTicket.CloserID); goodUser = _goodUsers.FindByEmail(badUser.Email); if (goodUser != null) { goodTicket.CloserID = goodUser.UserID; } else { goodTicket.CloserID = null; } } } //Reset ticket dates goodTicket.DateCreated = badTicket.DateCreatedUtc; goodTicket.DateModified = badTicket.DateModifiedUtc; goodTicket.ParentID = null; goodTicket.ImportID = _importID; if (badTicket.CreatorID > 0) { User creator = _usersAndContacts.FindByUserID(badTicket.CreatorID); if (creator != null) { goodTicket.CreatorID = creator.UserID; } else { goodTicket.CreatorID = -5; } } else { goodTicket.CreatorID = badTicket.CreatorID; } if (badTicket.ModifierID > 0) { User modifier = _usersAndContacts.FindByUserID(badTicket.ModifierID); if (modifier != null) { goodTicket.ModifierID = modifier.UserID; } else { goodTicket.ModifierID = -5; } } else { goodTicket.ModifierID = badTicket.ModifierID; } goodTicket.TicketNumber = 0; goodTicket.Collection.Save(); EmailPosts.DeleteImportEmails(loginUser); Actions badActions = new Actions(GetCorrupteLoginUser()); badActions.LoadByTicketID(badTicket.TicketID); foreach (TeamSupport.Data.Action badAction in badActions) { TeamSupport.Data.Action goodAction = new Actions(loginUser).AddNewAction(); goodAction.CopyRowData(badAction); goodAction.DateCreated = badAction.DateCreatedUtc; goodAction.DateModified = badAction.DateCreatedUtc; goodAction.TicketID = goodTicket.TicketID; goodAction.ImportID = _importID; if (badAction.CreatorID > 0) { User creator = _usersAndContacts.FindByUserID(badAction.CreatorID); if (creator != null) { goodAction.CreatorID = creator.UserID; } else { goodAction.CreatorID = -5; } } else { goodAction.CreatorID = badAction.CreatorID; } if (badAction.ModifierID > 0) { User modifier = _usersAndContacts.FindByUserID(badAction.ModifierID); if (modifier != null) { goodAction.ModifierID = modifier.UserID; } else { goodAction.ModifierID = -5; } } else { goodAction.ModifierID = badAction.ModifierID; } goodAction.Collection.Save(); EmailPosts.DeleteImportEmails(loginUser); } Organizations orgs = new Organizations(GetCorrupteLoginUser()); orgs.LoadBTicketID(badTicket.TicketID); foreach (Organization org in orgs) { Organization goodCompany = existingCompanies.FindByName(org.Name); if (org.ParentID == orgID && goodCompany != null) { goodTicket.Collection.AddOrganization(goodCompany.OrganizationID, goodTicket.TicketID); EmailPosts.DeleteImportEmails(loginUser); } } RecoverTicketCustomValues(orgID, badTicket.TicketID, goodTicket.TicketID); EmailPosts.DeleteImportEmails(loginUser); } catch (Exception ex) { _exceptionOcurred = true; ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover"); } } }