public HttpResponseMessage LookupByKey(string key)
        {
            IEnumerable <object> records = null;

            switch (key)
            {
            case "TYPE":
                records = ticketLookupService.listTicketType();
                break;

            case "SOURCE":
                records = ticketLookupService.listTicketSource();
                break;

            case "GROUP":
                records = ticketLookupService.listTicketTeam();
                break;

            case "CATEGORY":
                records = ticketLookupService.listTicketCategory();
                break;

            case "STATUS":
                records = ticketLookupService.listTicketStatus(true);
                break;

            case "PRIORITY":
                records = ticketLookupService.listTicketPriority();
                break;

            case "SLA":
                records = ticketLookupService.listTicketSLA();
                break;
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new { records = records }));
        }
Example #2
0
        // GET api/<controller>
        public HttpResponseMessage Get(string by = "User", int ticketId = 0)
        {
            try
            {
                if ("User".Equals(by))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { }));
                }

                TicketViewDto formData = null;

                if (ticketId > 0)
                {
                    formData = ticketService.loadTicket(ticketId);
                }

                IEnumerable <GeneralLookupDto> ticketAgents = null;
                IEnumerable <GeneralLookupDto> subCates     = null;
                IEnumerable <GeneralLookupDto> items        = null;
                EmployeeDto requestor = null;
                int?        priority  = null;
                if (formData != null)
                {
                    ticketAgents = ticketLookupService.listTicketAgent((int)formData.itemId);
                    subCates     = ticketLookupService.listTicketSubCate((int)formData.categoryId, false);
                    items        = ticketLookupService.listTicketItem((int)formData.subCateId);
                    IEmployeeService empService = new EmployeeService();
                    if (formData.empId > 0)
                    {
                        requestor = empService.GetEmployee(formData.empId);
                        priority  = formData.priorityId;
                    }
                }

                var data = new
                {
                    types      = ticketLookupService.listTicketType(false),
                    sources    = ticketLookupService.listTicketSource(),
                    statuses   = ticketLookupService.listTicketStatus(ticketId == 0? 2:1, formData == null?0: (int)formData.statusId),
                    impacts    = ticketLookupService.listTicketImpact(),
                    urgencies  = ticketLookupService.listTicketUrgency(),
                    priorities = ticketLookupService.listTicketPriority(),
                    sites      = ticketLookupService.listTicketSite(),
                    teams      = ticketLookupService.listTicketTeam(),
                    agents     = ticketAgents,
                    cates      = ticketLookupService.listTicketCategory(),
                    subCates   = subCates,
                    items      = items,
                    requestor  = requestor,
                    formData   = formData
                };

                return(Request.CreateResponse(HttpStatusCode.OK, data));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new
                {
                    status = "success",
                    message = e.Message
                }));
            }
        }