Example #1
0
        // GET: SupportTicket
        public ActionResult Index()
        {
            SupportTickets    supportTicket  = new SupportTickets();
            List <Department> departmentList = new List <Department>();

            supportTicket.RequestedByList = new List <SelectListItem>();
            supportTicket.Departments     = new List <SelectListItem>();
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                using (SqlCommand cmd = new SqlCommand("SELECT * FROM Department", connection))
                {
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader != null)
                        {
                            while (reader.Read())
                            {
                                var department = new Department();
                                department.DepartmentID   = Convert.ToInt32(reader["DepartmentID"]);
                                department.DepartmentName = (reader["DepartmentName"]).ToString();
                                supportTicket.Departments.Add(new SelectListItem {
                                    Text = department.DepartmentName, Value = department.DepartmentID.ToString()
                                });
                            }
                        }
                    }
                }
                connection.Close();
            }
            return(View(supportTicket));
        }
Example #2
0
        public IHttpActionResult PutSupportTickets(int id, SupportTickets supportTickets)
        {
            supportTickets.Id = id;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != supportTickets.Id)
            {
                return(BadRequest());
            }

            db.Entry(supportTickets).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SupportTicketsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("id,subject,problem,who,ClientId,state")] SupportTickets supportTickets)
        {
            if (id != supportTickets.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supportTickets);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupportTicketsExists(supportTickets.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientId"] = new SelectList(_context.Cliente, "id", "id", supportTickets.ClientId);
            return(View(supportTickets));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SupportTickets supportTickets = db.SupportTickets.Find(id);

            db.SupportTickets.Remove(supportTickets);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
        public ActionResult Index(SupportTickets supportTicket)
        {
            try
            {
                supportTicket.Departments = new List <SelectListItem>();
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();

                    using (SqlCommand cmd = new SqlCommand("SELECT * FROM Department", connection))
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader != null)
                            {
                                while (reader.Read())
                                {
                                    var department = new Department();
                                    department.DepartmentID   = Convert.ToInt32(reader["DepartmentID"]);
                                    department.DepartmentName = (reader["DepartmentName"]).ToString();
                                    supportTicket.Departments.Add(new SelectListItem {
                                        Text = department.DepartmentName, Value = department.DepartmentID.ToString()
                                    });
                                }
                            }
                        }
                    }
                    supportTicket.RequestedByList = new List <SelectListItem>();

                    using (SqlCommand cmd = new SqlCommand("SELECT * FROM Employee where departmentID=" + supportTicket.Department, connection))
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader != null)
                            {
                                while (reader.Read())
                                {
                                    var employee = new Employee();
                                    employee.DepartmentID = Convert.ToInt32(reader["DepartmentID"]);
                                    employee.EmployeeName = (reader["EmployeeName"]).ToString();
                                    employee.EmployeeID   = Convert.ToInt32(reader["EmployeeID"]);
                                    supportTicket.RequestedByList.Add(new SelectListItem {
                                        Text = employee.EmployeeName, Value = employee.EmployeeID.ToString()
                                    });
                                }
                            }
                        }
                    }
                }

                return(View(supportTicket));
            }
            catch (Exception ex)
            {
                return(View(supportTicket));
            }
        }
 public ActionResult Edit([Bind(Include = "Id,IdCliente,Usuario,Titulo,Detalle,Estado")] SupportTickets supportTickets)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supportTickets).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supportTickets));
 }
        public ActionResult Create([Bind(Include = "Id,IdCliente,Usuario,Titulo,Detalle,Estado")] SupportTickets supportTickets)
        {
            if (ModelState.IsValid)
            {
                db.SupportTickets.Add(supportTickets);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supportTickets));
        }
Example #8
0
        public IHttpActionResult GetSupportTickets(int id)
        {
            SupportTickets supportTickets = db.SupportTickets.Find(id);

            if (supportTickets == null)
            {
                return(NotFound());
            }

            return(Ok(supportTickets));
        }
Example #9
0
        public IHttpActionResult PostSupportTickets(SupportTickets supportTickets)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SupportTickets.Add(supportTickets);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = supportTickets.Id }, supportTickets));
        }
Example #10
0
        public async Task <IActionResult> Create([Bind("id,subject,problem,who,ClientId,state")] SupportTickets supportTickets)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supportTickets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientId"] = new SelectList(_context.Cliente, "id", "id", supportTickets.ClientId);
            return(View(supportTickets));
        }
Example #11
0
        public IHttpActionResult DeleteSupportTickets(int id)
        {
            SupportTickets supportTickets = db.SupportTickets.Find(id);

            if (supportTickets == null)
            {
                return(NotFound());
            }

            db.SupportTickets.Remove(supportTickets);
            db.SaveChanges();

            return(Ok(supportTickets));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SupportTickets = await _context.SupportTickets.AsNoTracking().FirstOrDefaultAsync(m => m.id == id);

            if (SupportTickets == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public ActionResult Create()
        {
            ViewBag.MiListado = ObtenerListado();
            var clientes = db.Clientes.ToList();

            var viewModel = new SupportTickets {
                Cliente = clientes
            };

            if (User.Identity.IsAuthenticated)
            {
                ViewBag.Nombre = User.Identity.Name;
            }

            return(View(viewModel));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SupportTickets = await _context.SupportTickets.FindAsync(id);

            if (SupportTickets != null)
            {
                _context.SupportTickets.Remove(SupportTickets);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupportTickets supportTickets = db.SupportTickets.Find(id);
            int            val            = Int32.Parse(supportTickets.IdCliente);
            Cliente        clientes       = db.Clientes.Find(val);

            ViewBag.Detalles = clientes.Nombre;
            if (supportTickets == null)
            {
                return(HttpNotFound());
            }
            return(View(supportTickets));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupportTickets supportTickets = db.SupportTickets.Find(id);
            int            val            = Int32.Parse(supportTickets.IdCliente);
            Cliente        clientes       = db.Clientes.Find(val);

            ViewBag.Edit          = clientes.Nombre;
            ViewBag.ListaClientes = GetClientes();
            ViewBag.MiListado     = ObtenerListado();
            if (supportTickets == null)
            {
                return(HttpNotFound());
            }
            return(View(supportTickets));
        }
Example #17
0
 public ActionResult Save(SupportTickets supportTicket)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         string format = "yyyy-MM-dd HH:mm:ss";
         connection.Open();
         using (SqlCommand cmd = new SqlCommand("INSERT into SupportTickets (ProjectName,DateTimeReceived,Department,RequestedBy,Description) values(" + "'" + supportTicket.ProjectName + "'" + "," + "'" + supportTicket.DateTimeReceived.ToString(format) + "'" + "," + "'" + supportTicket.Department + "'" + "," + "'" + supportTicket.RequestedBy + "'" + "," + "'" + supportTicket.Description + "'" + ")", connection))
         {
             int recordsAffected = cmd.ExecuteNonQuery();
             if (recordsAffected != 0)
             {
                 return(Json(new { success = true, responseText = "Successfully Saved!" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { success = false, responseText = "Application encountered an issue.. Please Check" }, JsonRequestBehavior.AllowGet));
             }
         }
     }
 }