Esempio n. 1
0
        /// <summary>
        /// Displays EditForm view with TicketData instance as the model
        /// </summary>
        /// <param name="td">TicketData instance</param>
        /// <returns>EditForm View with specified TicketData entry</returns>
        public async Task <ViewResult> EditForm(TicketData td)
        {
            try
            {
                Authorize();
            }
            catch (HttpResponseException e)
            {
                return(View("Error", Utility.CreateHttpErrorView(e, "You do not have the permissions to view this page")));
            }

            try
            {
                RecordRetriever rr    = new RecordRetriever();
                var             tdRes = rr.GetRecordByID(td.EntryId);
                return(View("EditForm", tdRes));
            }
            catch (HttpResponseException e)
            {
                ServerErrorViewModel error = await Utility.CreateServerErrorView(e);

                return(View("ServerError", error));
            }
            catch (Exception e)
            {
                var            guid  = ExceptionReporter.DumpException(e);
                ErrorViewModel error = Utility.CreateBasicExceptionView(e, guid);
                return(View("Error", error));
            }
        }
Esempio n. 2
0
 public void GetRecordByIDTest()
 {
     using (var context = new TicketingSystemDBContext())
     {
         var       td     = TestUtility.CreateTestData();
         DataEntry de     = new DataEntry();
         Users     dbUser = context.Users.Where(u => u.FullName == "Test User").FirstOrDefault();
         de.PostEntry(td, Auth0APIClient.GetUserData(dbUser.Auth0Uid));
         int             id  = context.TicketData.First().EntryId;
         RecordRetriever rr  = new RecordRetriever();
         var             res = rr.GetRecordByID(id);
         Assert.IsNotNull(res);
         Assert.IsTrue(res.GetType() == typeof(TicketData));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the TicketData entry based on Entry ID of ticket clicked on in HomePage table
        /// </summary>
        /// <param name="entryID">Entry ID specified in HomePage table</param>
        /// <returns>JSON containing redirect URL</returns>
        public async Task <JsonResult> OpenEntry(string entryID)
        {
            try
            {
                Authorize();
            }
            catch (HttpResponseException e)
            {
                return(Json(new
                {
                    newUrl = Url.Action("Error", Utility.CreateHttpErrorView(e, "401 Unauthorized"))
                }));
            }
            try
            {
                using (var context = new TicketingSystemDBContext())
                {
                    int             id = int.Parse(entryID);
                    RecordRetriever rr = new RecordRetriever();
                    TicketData      td = rr.GetRecordByID(id);


                    return(Json(new
                    {
                        newUrl = Url.Action("EntryClose", "Home", td)
                    }));
                }
            }
            catch (HttpResponseException e)
            {
                string guid = ExceptionReporter.DumpException(e);
                ServerErrorViewModel error = await Utility.CreateServerErrorView(e);

                return(Json(new
                {
                    newUrl = Url.Action("ServerError", error)
                }));
            }
            catch (Exception e)
            {
                string guid = ExceptionReporter.DumpException(e);
                return(Json(new
                {
                    newUrl = Url.Action("Error", Utility.CreateBasicExceptionView(e, guid))
                }));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the TicketData entry based on the entryID input in Index page
        /// </summary>
        /// <param name="entryId">Entry ID input from index</param>
        /// <returns>JSON holding redirect URL</returns>
        public async Task <JsonResult> GetRecord(string entryId)
        {
            try
            {
                Authorize();
            }
            catch (HttpResponseException e)
            {
                return(Json(new
                {
                    newUrl = Url.Action("Error", "Edit", Utility.CreateHttpErrorView(e, "You do not have the permissions to view this page"))
                }));
            }
            try
            {
                using (var context = new TicketingSystemDBContext())
                {
                    RecordRetriever rr     = new RecordRetriever();
                    var             result = rr.GetRecordByID(int.Parse(entryId));

                    return(Json(new
                    {
                        newUrl = Url.Action("EditForm", "Edit", result)
                    }));
                }
            }
            catch (HttpResponseException e)
            {
                string guid = ExceptionReporter.DumpException(e);
                ServerErrorViewModel error = await Utility.CreateServerErrorView(e);

                return(Json(new
                {
                    newUrl = Url.Action("ServerError", error)
                }));
            }
            catch (Exception e)
            {
                string guid = ExceptionReporter.DumpException(e);
                return(Json(new
                {
                    newUrl = Url.Action("Error", Utility.CreateBasicExceptionView(e, guid))
                }));
            }
        }