public JsonResult Valdate(string justification, string ports, SimplePortDirectionTypeConstant?direction, PortTypeConstant?portType)
        {
            var errors = new Dictionary <string, string>();
            var ret    = _portFactory.Validate(ports);

            if (!ret.IsValid)
            {
                errors.Add("ports", $"The ports entered were not valid.  The valid configuration is {ret.Ports.ToPortString()}");
            }
            if (!_justificationFactory.IsValidText(justification))
            {
                errors.Add("justification", "The Justifcation cannot be empty whitespace.");
            }

            if (!direction.HasValue)
            {
                errors.Add("direction", "You must choose a direction");
            }

            if (!portType.HasValue)
            {
                errors.Add("portType", "You must choose a type");
            }

            if (errors.Count == 0)
            {
                return(Json(JsonEnvelope.Success()));
            }

            return(Json(JsonEnvelope.Error(errors)));
        }
        public async Task <JsonResult> Add(JustificationTypeConstant id, long specId, string text)
        {
            if (!_justificationFactory.IsValidText(text))
            {
                return(Json(JsonEnvelope.Error("The Justifcation cannot be empty whitespace.")));
            }

            var newid = await _justificationFactory.AddJustification(id, specId, text);

            Logger.LogInformation($"Justification {newid} added by {UserSecurity.SamAccountName} with text: {text}");

            return(Json(JsonEnvelope.Success(new { url = Url.PartialGetJustification(newid) })));
        }