public JsonResult AddTechNote(int ticketId, string note) { //get the ticket that was passed in and pull the associated record //get the current logged on employee (the tech working on the ticket) //this only works cause of stuff we made happen yeah TSTTicket ticket = db.TSTTickets.Single(x => x.TicketID == ticketId); TSTEmployee tech = GetCurrentEmployee(); if (tech != null) { TSTTechNote newNote = new TSTTechNote() { TicketID = ticketId, TechID = tech.EmpID, NotationDate = DateTime.Now, Notation = note }; db.TSTTechNotes.Add(newNote); db.SaveChanges(); var data = new { TechNotes = newNote.Notation, Tech = newNote.TSTEmployee.GetFullName, Date = string.Format("{0:g}", newNote.NotationDate) }; return(Json(data, JsonRequestBehavior.AllowGet)); } return(null); }
public ActionResult DeleteConfirmed(int id) { TSTTicket tSTTicket = db.TSTTickets.Find(id); db.TSTTickets.Remove(tSTTicket); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TicketID,StatusID,SubmissionDate,SubmittedByID,CompletedDate,TicketDesc,AssignedTechID")] TSTTicket tSTTicket) { if (ModelState.IsValid) { db.Entry(tSTTicket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.SubmittedByID = new SelectList(db.TSTEmployees, "EmpID", "fname", tSTTicket.SubmittedByID); ViewBag.AssignedTechID = new SelectList(db.TSTEmployees.Where(x => x.DeptID == 2), "EmpID", "FullName", tSTTicket.AssignedTechID); ViewBag.StatusID = new SelectList(db.TSTTicketStatuses, "StatusID", "StatusName", tSTTicket.StatusID); return(View(tSTTicket)); }
public ActionResult Edit([Bind(Include = "TicketID,TicketSubject,TicketDescription,SubmittedByID,TechID,TicketSubmitted,TicketResolved,TicketStatusID,Image,PriorityID")] TSTTicket tSTTicket) { if (ModelState.IsValid) { db.Entry(tSTTicket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TechID = new SelectList(db.TSTEmployees.Where(x => x.DepartmentID == 3), "EmpID", "EmpFname", tSTTicket.TechID); ViewBag.PriorityID = new SelectList(db.TSTPriorites, "PriorityID", "PriorityName", tSTTicket.PriorityID); ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses.Where(x => x.TicketStatusID != 1), "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID); return(View(tSTTicket)); }
// GET: TSTTickets/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSTTicket tSTTicket = db.TSTTickets.Find(id); if (tSTTicket == null) { return(HttpNotFound()); } return(View(tSTTicket)); }
public ActionResult Edit([Bind(Include = "TicketID,TicketSubject,TicketDescription,TicketImage,SubmittedByID,DateSubmitted,TicketStatusID,TechID,PriorityID,DateResolved")] TSTTicket tSTTicket) { if (ModelState.IsValid) { db.Entry(tSTTicket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TechID = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTTicket.TechID); ViewBag.SubmittedByID = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTTicket.SubmittedByID); ViewBag.PriorityID = new SelectList(db.TSTPriorities, "PriorityID", "PriorityName", tSTTicket.PriorityID); ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses, "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID); return(View(tSTTicket)); }
public ActionResult Edit([Bind(Include = "ID,SubmitedByID,TechID,CreatedDate,ResolutionDate,Description,StatusID,PriorityID,Subject")] TSTTicket tSTTicket) { if (ModelState.IsValid) { db.Entry(tSTTicket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubmitedByID = new SelectList(db.TSTEmployees, "ID", "Fname", tSTTicket.SubmitedByID); ViewBag.TechID = new SelectList(db.TSTEmployees.Where(e => e.TSTDepartment.ID == 7), "ID", "Fname", tSTTicket.TechID); ViewBag.PriorityID = new SelectList(db.TSTTicketPriorities, "ID", "Name", tSTTicket.PriorityID); ViewBag.StatusID = new SelectList(db.TSTTicketStatuses, "ID", "Name", tSTTicket.StatusID); return(View(tSTTicket)); }
//AddTechNote() /// <summary> /// Notation informations: /// This is the method that is going to be called by jquery/Ajax from the edie /// view to add the note on the fly and persist it to the (Tech)Notes Table /// it will post the NEW note to the view in the notes section BEFORE submitting the /// form. /// </summary> public JsonResult AddTechNote(int ticketId, string note) { //get the ticket that was passed in to the method and retrieve the associated //record. TSTTicket ticket = db.TSTTickets.Single(x => x.TicketID == ticketId); //get the current logged on employee so taht we can fulfill the //TechID field for the TSTTechNote TSTEmployee tech = GetCurrentEmoloyee(); //Make the note //make sure the TSTEmployee is not null if (tech != null) { //Create the TSTNote object TSTTicketNote newNote = new TSTTicketNote() { //object initialization syntax //property = (is assiged the value) of //hard coded / passed in data TicketID = ticketId, //passed into the method Notation = note, //passed into the method EmpID = tech.EmpID, //derived NotationDate = DateTime.Now }; //Persist the note at the data structure //save changes db.TSTTicketNotes.Add(newNote); db.SaveChanges(); //----the note is created - exists at the data structure //now we need to send it back to the view, so we can display it in the //edit view //This NEVER hits the wevserver, jQuery has not idea what the TSTNote //objec is. We send over datat that can be parsed by jQuery. var data = new { //otf (on the fly variable) = newNote.Property TechNotes = newNote.Notation, Tech = newNote.TSTEmployee.fname, Date = string.Format("{0:g}", newNote.NotationDate) //because this doesn't hit the webserver, we format it here }; //send notation infor to the browser for jQuery to parse return(Json(data, JsonRequestBehavior.AllowGet)); }//end the if return(null);//no note if employee is null. }//ends the AddNewNote()
public ActionResult DeleteConfirmed(int id) { TSTTicket tSTTicket = db.TSTTickets.Find(id); var currentUserId = User.Identity.GetUserId(); //create user employee relationship by matching user id to user id of employee TSTEmployee e = db.TSTEmployees.FirstOrDefault(x => x.EmpUserID == currentUserId); if (e.DepartmentID == 1 || e.DepartmentID == 3) { switch (tSTTicket.TicketStatusID) { case 1: //assign ticket tSTTicket.TicketStatusID = 2; tSTTicket.TSTEmployee1 = e; break; case 2: tSTTicket.TicketStatusID = 3; //move it to in progress status break; case 3: tSTTicket.TicketStatusID = 4; //resolve the ticket tSTTicket.TicketResolved = DateTime.Now; tSTTicket.PriorityID = 1; break; case 4: tSTTicket.TicketStatusID = 1; //reopen ticket un asssign from tech. Put in very high priority tSTTicket.TechID = null; tSTTicket.PriorityID = 4; break; default: break; } } db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: TSTTickets/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSTTicket tSTTicket = db.TSTTickets.Find(id); ViewBag.PassImg = tSTTicket.Image; if (tSTTicket == null) { return(HttpNotFound()); } return(View(tSTTicket)); }
// GET: TSTTickets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSTTicket tSTTicket = db.TSTTickets.Find(id); if (tSTTicket == null) { return(HttpNotFound()); } ViewBag.SubmittedByID = new SelectList(db.TSTEmployees, "EmpID", "fname", tSTTicket.SubmittedByID); ViewBag.AssignedTechID = new SelectList(db.TSTEmployees.Where(x => x.DeptID == 2), "EmpID", "FullName", tSTTicket.AssignedTechID); ViewBag.StatusID = new SelectList(db.TSTTicketStatuses, "StatusID", "StatusName", tSTTicket.StatusID); return(View(tSTTicket)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSTTicket tSTTicket = db.TSTTickets.Find(id); if (tSTTicket == null) { return(HttpNotFound()); } ViewBag.TechID = new SelectList(db.TSTEmployees.Where(x => x.DepartmentID == 3), "EmpID", "EmpFname", tSTTicket.TechID); ViewBag.PriorityID = new SelectList(db.TSTPriorites, "PriorityID", "PriorityName", tSTTicket.PriorityID); ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses.Where(x => x.TicketStatusID != 1), "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID); return(View(tSTTicket)); }
public ActionResult Create([Bind(Include = "TicketID,StatusID,SubmissionDate,SubmittedByID,CompletedDate,TicketDesc,AssignedTechID")] TSTTicket tSTTicket) { if (ModelState.IsValid) { tSTTicket.SubmittedByID = GetCurrentEmoloyee().EmpID; tSTTicket.SubmissionDate = DateTime.Now; tSTTicket.StatusID = 1; db.TSTTickets.Add(tSTTicket); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.SubmittedByID = new SelectList(db.TSTEmployees, "EmpID", "fname", tSTTicket.SubmittedByID); //ViewBag.AssignedTechID = new SelectList(db.TSTEmployees, "EmpID", "fname", tSTTicket.AssignedTechID); //ViewBag.StatusID = new SelectList(db.TSTTicketStatuses, "StatusID", "StatusName", tSTTicket.StatusID); return(View(tSTTicket)); }
// GET: Tickets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSTTicket tSTTicket = db.TSTTickets.Find(id); if (tSTTicket == null) { return(HttpNotFound()); } ViewBag.TechID = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTTicket.TechID); ViewBag.SubmittedByID = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTTicket.SubmittedByID); ViewBag.PriorityID = new SelectList(db.TSTPriorities, "PriorityID", "PriorityName", tSTTicket.PriorityID); ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses, "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID); return(View(tSTTicket)); }
// GET: TSTTickets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSTTicket tSTTicket = db.TSTTickets.Find(id); if (tSTTicket == null) { return(HttpNotFound()); } ViewBag.SubmitedByID = new SelectList(db.TSTEmployees, "ID", "Fname", tSTTicket.SubmitedByID); ViewBag.TechID = new SelectList(db.TSTEmployees.Where(e => e.TSTDepartment.ID == 7), "ID", "Fname", tSTTicket.TechID); ViewBag.PriorityID = new SelectList(db.TSTTicketPriorities, "ID", "Name", tSTTicket.PriorityID); ViewBag.StatusID = new SelectList(db.TSTTicketStatuses, "ID", "Name", tSTTicket.StatusID); return(View(tSTTicket)); }
/// <summary> /// Notation Information: /// This is the method that is going to be called by jQuery/Ajax from the edit view to add the note on the fly AND post it to the notes section BEFORE submitting the form. /// /// AJAX - Asynchronous JavaScript and XML (makes calles without reloading page) /// /// </summary> public JsonResult AddTechNote(int ticketID, string note) { // get the ticketID passed in to the method and get the associated record TSTTicket ticket = db.TSTTickets.Single(x => x.ID == ticketID); // Get the current logged on employee ( who is working the ticket) TSTEmployee tech = db.TSTEmployees.Single(x => x.Email == User.Identity.Name); // this code requires all employees are associated to a user ID in Identity // This code only works because we associated the TSTEmployee table to the Identity AspNetUser Table // make sure the tech is not null if (tech != null) { // create TstNote object and submit TSTTechNote newNote = new TSTTechNote() { // Property is assigned a value TicketID = ticketID, // passed thru the method TechID = tech.ID, // derived from employee above TimeCreated = DateTime.Now, // hard coded Notes = note // passed in thru the method }; // add note record to the table db.TSTTechNotes.Add(newNote); db.SaveChanges(); //return data to the view to be displayed. This NEVER hits the webserver, so jQuery has NO IDEA what a TSTTechNote. // We send over data that can be parsed by jQuery. var data = new { // On the Fly Variable = newNote.Property, TechNotes = newNote.Notes, Tech = newNote.TSTEmployee.Fname, Date = string.Format("{0:g}", newNote.TimeCreated) // never hits webserver so formatting is done here }; // send note information back to the browser for jQuery to parse return(Json(data, JsonRequestBehavior.AllowGet)); } return(null); }
public JsonResult ChangePhoto(int Id, string img) { if (img != null) { TSTTicket tSTTicket = db.TSTTickets.Find(Id); string imageName = img.Substring(img.LastIndexOf('/') + 1); tSTTicket.Image = imageName; db.SaveChanges(); var data = new { Id = tSTTicket.TicketID, Image = tSTTicket.Image }; return(Json(data, JsonRequestBehavior.AllowGet)); } return(null); }
public ActionResult Create([Bind(Include = "TicketID,TicketSubject,TicketDescription,SubmittedByID,TechID,TicketSubmitted,TicketResolved,TicketStatusID,Image,PriorityID")] TSTTicket tSTTicket) { if (ModelState.IsValid) { TSTEmployee e = GetCurrentEmployee(); tSTTicket.SubmittedByID = e.EmpID; tSTTicket.TicketSubmitted = DateTime.Now; tSTTicket.TicketStatusID = 1; tSTTicket.Image = "Noimage.png"; tSTTicket.PriorityID = 1; db.TSTTickets.Add(tSTTicket); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubmittedByID = new SelectList(db.TSTEmployees, "EmpID", "EmpFname", tSTTicket.SubmittedByID); ViewBag.TechID = new SelectList(db.TSTEmployees, "EmpID", "EmpFname", tSTTicket.TechID); ViewBag.PriorityID = new SelectList(db.TSTPriorites, "PriorityID", "PriorityName", tSTTicket.PriorityID); ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses, "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID); return(View(tSTTicket)); }
public ActionResult Create([Bind(Include = "ID,SubmitedByID,TechID,CreatedDate,ResolutionDate,Description,StatusID,PriorityID,Subject")] TSTTicket tSTTicket) { if (ModelState.IsValid) { TSTEmployee e = db.TSTEmployees.FirstOrDefault(x => x.Email == User.Identity.Name); tSTTicket.SubmitedByID = e.ID; tSTTicket.CreatedDate = DateTime.Now; tSTTicket.StatusID = 1; tSTTicket.PriorityID = 3; db.TSTTickets.Add(tSTTicket); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubmitedByID = new SelectList(db.TSTEmployees, "ID", "Fname", tSTTicket.SubmitedByID); ViewBag.TechID = new SelectList(db.TSTEmployees, "ID", "Fname", tSTTicket.TechID); ViewBag.PriorityID = new SelectList(db.TSTTicketPriorities, "ID", "Name", tSTTicket.PriorityID); ViewBag.StatusID = new SelectList(db.TSTTicketStatuses, "ID", "Name", tSTTicket.StatusID); return(View(tSTTicket)); }