public IActionResult Ready(int id)
        {
            var stage = _context.Stagings.FirstOrDefault(m => m.Id == id);

            if (stage == null)
            {
                return(Json(new JsonResponse("not ready")));
            }

            var textractform = new TextractDocument.TextractDocument();

            foreach (var a in JArray.Parse(stage.ParsedTextractJSON))
            {
                var childform = new TextractDocument.TextractDocument();
                childform.FromJson(a);
                textractform.AddPages(childform);
            }

            AbstractFormObject ts;

            try
            {
                ts = AbstractFormObject.FromTextract(textractform, stage.formType);
            }
            catch (Exception)
            {
                return(Json(new JsonResponse("invalid")));
            }

            ts.id = id;

            return(Json(ts));
        }
        public IActionResult Submit(int id)
        {
            var stage = _context.Stagings.FirstOrDefault(m => m.Id == id);

            if (stage == null)
            {
                return(Json(new JsonResponse("not ready")));
            }
            var textractform = new TextractDocument.TextractDocument();

            foreach (var a in JArray.Parse(stage.ParsedTextractJSON))
            {
                var childform = new TextractDocument.TextractDocument();
                childform.FromJson(a);
                textractform.AddPages(childform);
            }
            var ts = AbstractFormObject.FromTextract(textractform, stage.formType);

            ts.id = id;

            var PWAForm = PWAsubmission.FromForm(ts, stage.formType);

            switch (stage.formType)
            {
            case AbstractFormObject.FormType.OR507_RELIEF:
                return(SubmitTimesheet((PWATimesheet)PWAForm));

            case AbstractFormObject.FormType.OR004_MILEAGE:
                return(SubmitMileage((PWAMileage)PWAForm));

            default:
                return(Json(new
                {
                    response = "invalid"
                }
                            ));
            }
        }