public bool DeleteAdministrator(string username) { Administrator administrator; using (var db = new EticketContext()) { administrator = db.Administrators.SingleOrDefault(s => s.Username == username); if (administrator == null) { Console.WriteLine("User not found under the specified criteria. Press any key to continue"); Console.ReadKey(); return(false); } else { db.Administrators.Remove(administrator); db.SaveChanges(); administrator = db.Administrators.SingleOrDefault(s => s.Username == username); if (administrator == null) { return(true); } else { return(false); } } } }
public bool DeleteNewUser(string username) { NewUser newUser; using (var db = new EticketContext()) { newUser = db.NewUsers.SingleOrDefault(s => s.Username == username); if (newUser != null) { db.NewUsers.Remove(newUser); db.SaveChanges(); } else { Console.WriteLine("No users found with this username. Press any key to return"); Console.ReadKey(); } newUser = db.NewUsers.SingleOrDefault(s => s.Username == username); if (newUser == null) { return(true); } else { return(false); } } }
public void DeleteTicket(int ticketID) { CustTicket ticket = new CustTicket(); using (var db = new EticketContext()) { ticket = db.CustTickets.FirstOrDefault(x => x.TicketID == ticketID && x.Closed == true); if (ticket == null) { Console.WriteLine("Ticket not found under the specified criteria. Press any key to continue"); Console.ReadKey(); } else { Console.Write($"Are you sure you want to delete Customer Ticket with ID- {ticket.TicketID}? (Y/N) "); string selection = Console.ReadLine(); if (selection == "Y" || selection == "y") { db.CustTickets.Remove(ticket); db.SaveChanges(); ticket = db.CustTickets.SingleOrDefault(s => s.TicketID == ticketID); if (ticket == null) { Console.WriteLine("Ticket deleted."); } else { Console.WriteLine("Ticket couldn't be deleted."); } } } } }
public void assignUsersToTicket(int ticketID) { CustTicketForm form = new CustTicketForm(); CustTicket ticket = new CustTicket(); using (var db = new EticketContext()) { ticket = db.CustTickets.FirstOrDefault(x => x.TicketID == ticketID); } if (ticket == null) { Console.WriteLine("Ticket couldn't be found. Press any key to return."); Console.ReadKey(); } else { CustTicket updatedTicket = form.CustTicketFormAssignUsers(ticket); using (var db = new EticketContext()) { ticket = db.CustTickets.SingleOrDefault(s => s.TicketID == ticket.TicketID); ticket.CSAgent = updatedTicket.CSAgent; ticket.TechSupport = updatedTicket.TechSupport; ticket.Closed = updatedTicket.Closed; db.SaveChanges(); } string updatedTicketToText = ($" Date: {updatedTicket.Date} - CustomerName: {updatedTicket.CustomerName} - Customer Email: {updatedTicket.CustomerEmail} - Customer Phone: {updatedTicket.CustomerPhone} - Description: {updatedTicket.Description} - TicketID: {updatedTicket.TicketID} \n"); File.AppendAllText("CustTicketArchive.txt", updatedTicketToText); } }
public List <TechSupportUser> GetAllTechSupportUsers() { List <TechSupportUser> allTechSupportUsers = new List <TechSupportUser>(); using (var db = new EticketContext()) { allTechSupportUsers = db.TechSupportUsers.ToList(); } return(allTechSupportUsers); }
public TechSupportUser GetTechSupportUser(string email, string name) { TechSupportUser techSupportUser; using (var db = new EticketContext()) { techSupportUser = db.TechSupportUsers.SingleOrDefault(s => s.Email == email || s.Name == name); } return(techSupportUser); }
public TechSupportUser GetTechSupportUser(string username) { TechSupportUser techSupportUser; using (var db = new EticketContext()) { techSupportUser = db.TechSupportUsers.Find(username); } return(techSupportUser); }
public List <Supervisor> GetAllSupervisors() { List <Supervisor> allSupervisors = new List <Supervisor>(); using (var db = new EticketContext()) { allSupervisors = db.Supervisors.ToList(); } return(allSupervisors); }
public Supervisor GetSupervisor(string email, string name) { Supervisor supervisor; using (var db = new EticketContext()) { supervisor = db.Supervisors.SingleOrDefault(s => s.Email == email || s.Name == name); } return(supervisor); }
public CSAgent GetCSAgent(string username) { CSAgent cSAgent; using (var db = new EticketContext()) { cSAgent = db.CSAgents.SingleOrDefault(s => s.Username == username); } return(cSAgent); }
public Administrator GetAdministrator(string username) { Administrator administrator; using (var db = new EticketContext()) { administrator = db.Administrators.Find(username); } return(administrator); }
//newUser Registration #region public List <NewUser> GetNewUser() { List <NewUser> allNewUsers = new List <NewUser>(); using (var db = new EticketContext()) { allNewUsers = db.NewUsers.ToList(); } return(allNewUsers); }
public List <CSAgent> GetAllCSAgents() { List <CSAgent> allCSAgents = new List <CSAgent>(); using (var db = new EticketContext()) { allCSAgents = db.CSAgents.ToList(); } return(allCSAgents); }
public Supervisor GetSupervisor(string username) { Supervisor supervisor; using (var db = new EticketContext()) { supervisor = db.Supervisors.Find(username); } return(supervisor); }
public CSAgent GetCSAgent(string email, string name) { CSAgent cSAgent; using (var db = new EticketContext()) { cSAgent = db.CSAgents.SingleOrDefault(s => s.Email == email || s.Name == name); } return(cSAgent); }
public List <Administrator> GetAllAdministrators() { List <Administrator> allAdministrators = new List <Administrator>(); using (var db = new EticketContext()) { allAdministrators = db.Administrators.ToList(); } return(allAdministrators); }
public Administrator GetAdministrator(string email, string name) { Administrator administrator; using (var db = new EticketContext()) { administrator = db.Administrators.SingleOrDefault(s => s.Email == email || s.Name == name); } return(administrator); }
//CRUD for Customer Tickets #region public void SubmitNewTicket(string username) { CustTicketForm form = new CustTicketForm(); CustTicket newTicket = new CustTicket(); newTicket = form.CustTicketFormEmpty(username); using (var db = new EticketContext()) { db.CustTickets.Add(newTicket); db.SaveChanges(); } string newTicketToText = ($" Date: {newTicket.Date} - CustomerName: {newTicket.CustomerName} - Customer Email: {newTicket.CustomerEmail} - Customer Phone: {newTicket.CustomerPhone} - Description: {newTicket.Description} - TicketID: {newTicket.TicketID}\n"); File.AppendAllText("CustTicketArchive.txt", newTicketToText); }
public CSAgent updateCSAgentInfo(string username, string password, string name, string phone, string email) { CSAgent cSAgent; using (var db = new EticketContext()) { cSAgent = db.CSAgents.SingleOrDefault(s => s.Username == username); cSAgent.Name = name; cSAgent.PhoneNumber = phone; cSAgent.Email = email; cSAgent.Password = password; db.SaveChanges(); cSAgent = db.CSAgents.SingleOrDefault(s => s.Username == username); } return(cSAgent); }
public Supervisor updateSupervisorInfo(string username, string password, string name, string phone, string email) { Supervisor supervisor; using (var db = new EticketContext()) { supervisor = db.Supervisors.SingleOrDefault(s => s.Username == username); supervisor.Name = name; supervisor.PhoneNumber = phone; supervisor.Email = email; supervisor.Password = password; db.SaveChanges(); supervisor = db.Supervisors.SingleOrDefault(s => s.Username == username); } return(supervisor); }
public TechSupportUser updateTechSupportUserInfo(string username, string password, string name, string phone, string email) { TechSupportUser techSupportUser; using (var db = new EticketContext()) { techSupportUser = db.TechSupportUsers.SingleOrDefault(s => s.Username == username); techSupportUser.Name = name; techSupportUser.PhoneNumber = phone; techSupportUser.Email = email; techSupportUser.Password = password; db.SaveChanges(); techSupportUser = db.TechSupportUsers.SingleOrDefault(s => s.Username == username); } return(techSupportUser); }
public Administrator updateAdministratorInfo(string username, string password, string name, string phone, string email) { Administrator administrator; using (var db = new EticketContext()) { administrator = db.Administrators.SingleOrDefault(s => s.Username == username); administrator.Name = name; administrator.PhoneNumber = phone; administrator.Email = email; administrator.Password = password; db.SaveChanges(); administrator = db.Administrators.SingleOrDefault(s => s.Username == username); } return(administrator); }
//TechSupportUsers CRUD #region public TechSupportUser CreateTechSupportUser(string name, string email, string phone, string username, string password) { TechSupportUser newTechSupportUser = new TechSupportUser() { Name = name, Email = email, PhoneNumber = phone, Username = username, Password = password }; using (var db = new EticketContext()) { db.TechSupportUsers.Add(newTechSupportUser); db.SaveChanges(); } return(newTechSupportUser); }
// Administrators CRUD #region public Administrator CreateAdministrator(string name, string email, string phone, string username, string password) { Administrator newAdministrator = new Administrator() { Name = name, Email = email, PhoneNumber = phone, Username = username, Password = password }; using (var db = new EticketContext()) { db.Administrators.Add(newAdministrator); db.SaveChanges(); } return(newAdministrator); }
//csAgents CRUD #region public CSAgent CreateCSAgent(string name, string email, string phone, string username, string password) { CSAgent newCSAgent = new CSAgent() { Name = name, Email = email, PhoneNumber = phone, Username = username, Password = password }; using (var db = new EticketContext()) { db.CSAgents.Add(newCSAgent); db.SaveChanges(); } return(newCSAgent); }
public void RegisterUser() { NewUser newUser = new NewUser(); using (var db = new EticketContext()) { newUser = db.NewUsers.FirstOrDefault(); if (newUser != null) { Console.Write($"The applicant user has selected a role of {newUser.Role}. \n Applicant info: Username - { newUser.Username} \n Password - { newUser.Password} \n" + $" Name - {newUser.Name} \n Email - {newUser.Email} \n Phone Number - {newUser.PhoneNumber} \n Select what kind of user you want to register:" + $" 1. Administrator, 2. Supervisor, 3. TechSupport User, 4. CSAgent \n"); string selection = Console.ReadLine(); switch (selection) { case "1": CreateAdministrator(newUser.Name, newUser.Email, newUser.PhoneNumber, newUser.Username, newUser.Password); DeleteNewUser(newUser.Username); break; case "2": CreateSupervisor(newUser.Name, newUser.Email, newUser.PhoneNumber, newUser.Username, newUser.Password); DeleteNewUser(newUser.Username); break; case "3": CreateTechSupportUser(newUser.Name, newUser.Email, newUser.PhoneNumber, newUser.Username, newUser.Password); DeleteNewUser(newUser.Username); break; case "4": CreateCSAgent(newUser.Name, newUser.Email, newUser.PhoneNumber, newUser.Username, newUser.Password); DeleteNewUser(newUser.Username); break; default: Console.WriteLine("You made an invalid selection"); break; } } } }
public void FindOpenTicketsByName(string customerName) { CustTicketForm form = new CustTicketForm(); List <CustTicket> tickets = new List <CustTicket>(); using (var db = new EticketContext()) { tickets = db.CustTickets.Where(x => x.CustomerName == customerName && x.Closed == false).ToList(); } if (tickets == null) { Console.WriteLine("No tickets found with these criteria."); } else { foreach (var item in tickets) { form.CustTicketFormFilled(item); } } }
public void SearchAllTicketsByEmail(string customerEmail) { CustTicketForm form = new CustTicketForm(); List <CustTicket> tickets = new List <CustTicket>(); using (var db = new EticketContext()) { tickets = db.CustTickets.Where(x => x.CustomerEmail == customerEmail).ToList(); } if (tickets == null) { Console.WriteLine("No tickets found with these criteria."); } else { foreach (var item in tickets) { form.CustTicketFormFilled(item); } } }
public void ListAllTickets() { CustTicketForm form = new CustTicketForm(); List <CustTicket> tickets = new List <CustTicket>(); using (var db = new EticketContext()) { tickets = db.CustTickets.ToList(); } if (tickets == null) { Console.WriteLine("No tickets found in database."); } else { foreach (var item in tickets) { form.CustTicketFormFilled(item); } } }
public bool DeleteCSAgent(string username) { List <CustTicket> deleteCSagentFromTicket = new List <CustTicket>(); CSAgent cSAgent; using (var db = new EticketContext()) { cSAgent = db.CSAgents.SingleOrDefault(s => s.Username == username); if (cSAgent == null) { Console.WriteLine("User not found under the specified criteria. Press any key to continue"); Console.ReadKey(); return(false); } else { deleteCSagentFromTicket = db.CustTickets.Where(x => x.CSAgent == cSAgent.Username).ToList(); if (deleteCSagentFromTicket.Count > 0) { for (int i = 0; i < deleteCSagentFromTicket.Count; i++) { deleteCSagentFromTicket[i].CSAgent = null; db.SaveChanges(); } } db.CSAgents.Remove(cSAgent); db.SaveChanges(); cSAgent = db.CSAgents.SingleOrDefault(s => s.Username == username); if (cSAgent == null) { return(true); } else { return(false); } } } }