public List <TicketProfileView> GetAllTicketProfiles(bool resolved) { List <TicketProfileView> profiles = new List <TicketProfileView>(); using (mwdEntities db = new mwdEntities()) { TicketProfileView TPV; IQueryable <helpdesk> tickets; //var tickets = db.helpdesks.Where(o => o.StatusID != 3); if (resolved) { tickets = db.helpdesks.Where(o => o.StatusID == 3); } else { tickets = db.helpdesks.Where(o => o.StatusID != 3); } foreach (helpdesk h in tickets) { TPV = new TicketProfileView(); TPV.ID = h.ID; TPV.UserID = h.UserID; TPV.Comments = h.Comments; TPV.SeverityID = h.SeverityID; TPV.StatusID = h.StatusID; TPV.DepartmentID = h.DepartmentID; TPV.RowCreatedDateTime = h.RowCreatedDateTime; var SUP = db.SYSUsers.Find(h.UserID); if (SUP != null) { TPV.LoginName = SUP.LoginName; } var SEV = db.Severities.Find(h.SeverityID); if (SEV != null) { TPV.Severity = SEV.Severity1; } var STA = db.Status.Find(h.StatusID); if (STA != null) { TPV.Status = STA.Status1; } var DEP = db.Departments.Find(h.DepartmentID); if (DEP != null) { TPV.Department = DEP.Department1; } profiles.Add(TPV); } } return(profiles); }
public void UpdateTicket(TicketProfileView ticket) { using (mwdEntities db = new mwdEntities()) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { helpdesk HD = db.helpdesks.Find(ticket.ID); HD.UserID = ticket.UserID; HD.SeverityID = ticket.SeverityID; HD.StatusID = ticket.StatusID; HD.DepartmentID = ticket.DepartmentID; HD.Comments = ticket.Comments; HD.RowModifiedSYSUserID = ticket.SYSUserID; HD.RowModifiedDateTime = DateTime.Now; db.SaveChanges(); dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } } }
public ActionResult EditTicket(int id) { TicketManager TM = new TicketManager(); TicketProfileView TPV = TM.GetTicketProfile(id); return(View(TPV)); }
public ActionResult EditTicket(TicketProfileView profile) { TicketManager TM = new TicketManager(); UserManager UM = new UserManager(); profile.UserID = UM.GetUserID(profile.LoginName); string user = User.Identity.Name; profile.SYSUserID = UM.GetUserID(user); TM.UpdateTicket(profile); ViewBag.Status = "Update Sucessful!"; return(View(profile)); }
public TicketProfileView GetTicketProfile(int ticketID) { TicketProfileView TPV = new TicketProfileView(); using (mwdEntities db = new mwdEntities()) { var ticket = db.helpdesks.Find(ticketID); if (ticket != null) { TPV.ID = ticket.ID; TPV.UserID = ticket.UserID; TPV.Comments = ticket.Comments; TPV.SeverityID = ticket.SeverityID; TPV.StatusID = ticket.StatusID; TPV.DepartmentID = ticket.DepartmentID; TPV.RowCreatedDateTime = ticket.RowCreatedDateTime; var SUP = db.SYSUsers.Find(ticket.UserID); if (SUP != null) { TPV.LoginName = SUP.LoginName; } var SEV = db.Severities.Find(ticket.SeverityID); if (SEV != null) { TPV.Severity = SEV.Severity1; } var STA = db.Status.Find(ticket.StatusID); if (STA != null) { TPV.Status = STA.Status1; } var DEP = db.Departments.Find(ticket.DepartmentID); if (DEP != null) { TPV.Department = DEP.Department1; } } } return(TPV); }