public ActionResult UpdateTicket(AdmIssueViewModel model, int id)
        {
            string result = _ticketAdapter.UpdateTicket(model, id);

            if (result == "ok")
            {
                TimeLineHelper.TicketOperations(User.Identity.Name, TimeLineHelper.Operations.Edit, id);
            }
            else
            {
                TimeLineHelper.ErrorOperations(User.Identity.Name, TimeLineHelper.Operations.Edit, result, id);
            }
            return(RedirectToAction("UpdateTicket", new { id = id }));
        }
        public ActionResult AddTicket(CreateIssueViewModel model)
        {
            string result = _ticketAdapter.AddTicket(model, User.Identity.GetUserId(), User.Identity.GetUserName());

            if (result.Contains("error"))
            {
                TimeLineHelper.ErrorOperations(User.Identity.Name, TimeLineHelper.Operations.New, result);
            }
            else
            {
                TimeLineHelper.TicketOperations(User.Identity.Name, TimeLineHelper.Operations.New, int.Parse(result));
            }
            return(RedirectToAction("ViewTickets"));
        }
        public ActionResult EditTicket(UpdateTicket model)
        {
            string result = _ticketAdapter.EditTicket(model, User.Identity.GetUserId(), User.Identity.GetUserName());

            if (result.Contains("error"))
            {
                TimeLineHelper.ErrorOperations(User.Identity.Name, TimeLineHelper.Operations.Edit, result);
            }
            else
            {
                TimeLineHelper.TicketOperations(User.Identity.Name, TimeLineHelper.Operations.Edit, model.IssueId);
            }


            return(RedirectToAction("ViewTickets"));
        }
        // This is used to update/add technician, the only differenct is that if it is a create, the userName will be null
        public ActionResult AddUpdateTech(AdmUserViewModel model, string userId)
        {
            string result = _ticketAdapter.AddUpdateUser(model, userId);

            if (result == "NewOk")
            {
                TimeLineHelper.UserOperations(model.FirstName + model.LastName, User.Identity.Name, TimeLineHelper.Operations.Edit);
            }
            else if (result == "EditOk")
            {
                TimeLineHelper.UserOperations(model.FirstName + model.LastName, User.Identity.Name, TimeLineHelper.Operations.New);
            }
            else
            {
                TimeLineHelper.ErrorOperations(User.Identity.Name, TimeLineHelper.Operations.Edit, result);
            }

            return(RedirectToAction("Users", new { role = model.Role }));
        }
        // Need to 1. Remove resolution, 2. Remove assignments, 3. Remove Ticket
        public ActionResult DeleteTicket(int id, string userId)
        {
            string result = _ticketAdapter.DeleteTicket(id, userId);

            if (result == "ok")
            {
                TimeLineHelper.TicketOperations(User.Identity.Name, TimeLineHelper.Operations.Delete, id);
            }
            else
            {
                TimeLineHelper.ErrorOperations(User.Identity.Name, TimeLineHelper.Operations.Delete, result, id);
            }
            // Came from ticket list return
            if (userId == "none")
            {
                return(RedirectToAction("Tickets"));
            }
            else // came from userpage return there
            {
                return(RedirectToAction("Technician", new { userId = userId }));
            }
        }
        public ActionResult DeleteTech(string userId)
        {
            string userRole = _ticketAdapter.GetUserRole(userId);
            string result   = _ticketAdapter.DeleteUser(userId);

            if (result == "ok")
            {
                TimeLineHelper.UserOperations(userId, User.Identity.Name, TimeLineHelper.Operations.Delete);
            }
            else
            {
                TimeLineHelper.ErrorOperations(User.Identity.Name, TimeLineHelper.Operations.Edit, result);
            }

            if (userRole != null)
            {
                return(RedirectToAction("Users", new { role = userRole }));
            }
            else
            {
                return(RedirectToAction("Users", new { role = "All" }));
            }
        }