private RedirectResult RedirectNext(NextSection next)
        {
            if (!next.Section.HasValue)
            {
                return(Redirect(CocActions.Complete()));
            }

            var action = SectionActionStrategy.For(next.Section.Value).Action(next.Id);

            return(Redirect(action));
        }
 public override string Action(string formId)
 {
     return(CocActions.Declaration(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.Evidence(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.PaymentDetails(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.HealthProfessional(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.ExpectedChildren(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.Options(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.Identity(formId));
 }
 public override string Action(string formId)
 {
     return(CocActions.Consent(formId));
 }
        public ActionResult Evidence(string id, Evidence evidence)
        {
            if (WasClicked(CocButtons.UploadFile))
            {
                if (Request.Files.Count == 0)
                {
                    ModelState.AddModelError("", "Could not upload file");
                    return(Evidence_Render(id, evidence));
                }

                var file = Request.Files[0];

                if (string.IsNullOrWhiteSpace(file.FileName))
                {
                    ModelState.AddModelError("", "Please select a file to upload");
                    return(Evidence_Render(id, evidence));
                }

                const int maxSize = 1024 * 1024 * 2;

                if (file.ContentLength > maxSize)
                {
                    ModelState.AddModelError("", "Please select a file that is smaller than 2MB");
                    return(Evidence_Render(id, evidence));
                }

                using (var br = new BinaryReader(file.InputStream))
                {
                    var addFile = new AddEvidenceFile
                    {
                        FormId   = id,
                        Filename = file.FileName,
                        Content  = br.ReadBytes((int)file.InputStream.Length),
                    };

                    return(Exec(addFile,
                                success: () => Redirect(CocActions.Evidence(id)),
                                failure: () => Evidence_Render(id, evidence)));
                }
            }
            else if (WasClicked(CocButtons.RemoveFile))
            {
                var cloudName = Request.Form[CocButtons.RemoveFile];

                var delFile = new RemoveEvidenceFile
                {
                    FormId    = id,
                    CloudName = cloudName,
                };

                return(Exec(delFile,
                            success: () => Redirect(CocActions.Evidence(id)),
                            failure: () => Evidence_Render(id, evidence)));
            }

            var cmd = new AddEvidence
            {
                FormId   = id,
                Evidence = evidence,
            };

            return(Exec(cmd,
                        success: next => RedirectNext(next),
                        failure: () => Evidence_Render(id, evidence)));
        }