Inheritance: System.Web.UI.Page
Ejemplo n.º 1
0
        public Form(string title, IEnumerable <Item> items, Button submit)
        {
            _title  = title;
            _items  = items.ToArray();
            _submit = submit;

            foreach (var item in _items)
            {
                item.Component.SetChildOf(this);
                item.Component.MustRender += TriggerRender;
            }

            _submit.SetChildOf(this);
            _submit.MustRender += TriggerRender;

            _submit.Activated += (sender, _) =>
            {
                var ev = new SubmittedEventArgs(new FormData(_items));
                Submitted?.Invoke(sender, ev);
                _result = ev.Result;
            };

            KeyPressed += OnKeyPressed;
            Focused    += OnFocused;
        }
Ejemplo n.º 2
0
        protected void onSubmit(object sender)
        {
            Submitted?.Invoke(sender);

            InterfaceManager.UpdateStep();
            InterfaceManager.DrawStep();
        }
Ejemplo n.º 3
0
 public static IEnumerable <ApprenticeshipModel> EligibleApprenticeships(this Submitted @event)
 {
     return(@event.Model.ApprenticeshipModels.Where(apprenticeship =>
                                                    !apprenticeship.WithdrawnByEmployer &&
                                                    !apprenticeship.WithdrawnByCompliance &&
                                                    apprenticeship.HasEligibleEmploymentStartDate));
 }
Ejemplo n.º 4
0
 protected async void OnSubmitAsync()
 {
     if (await ValidateAsync())
     {
         Submitted?.Invoke(this, EventArgs.Empty);
     }
 }
        public void TestInitialize()
        {
            Policy.addDriver("", "", default(DateTime), 3);
            submit = new Submitted();

            Assert.AreNotEqual(submit, null);
        }
Ejemplo n.º 6
0
 private void OnSubmit()
 {
     Submitted?.Invoke(new FeedbackRequest(
                           Subjects[this.subject.value],
                           this.title.text,
                           this.text.text
                           ));
 }
Ejemplo n.º 7
0
        private async Task OnSubmit()
        {
            var(resp, httpResp) = await Backend.SubscriptionCreateEmpty(Request);

            if (httpResp.IsSuccessStatusCode)
            {
                await Submitted.InvokeAsync(null);
                await Dismiss();
            }

            ValidationMessage = resp.Message;
        }
Ejemplo n.º 8
0
        private void SubmitTask()
        {
            TaskContext context = new TaskContext();
            Task        t       = new Task();

            t.Name        = TaskName;
            t.DueDate     = DueDate;
            t.Description = "test";
            context.Tasks.Add(t);
            context.SaveChanges();
            Submitted?.Invoke(this, new EventArgs());
        }
Ejemplo n.º 9
0
        private async Task OnSubmit()
        {
            Request.SubscriptionId = SelectedSubscriptionId;
            var(resp, httpResp)    = await Backend.VideoAdd(Request);

            if (httpResp.IsSuccessStatusCode)
            {
                await Submitted.InvokeAsync(null);
                await Dismiss();
            }

            ValidationMessage = resp.Message;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// To service model
 /// </summary>
 /// <returns></returns>
 public CertificateRequestRecordModel ToServiceModel()
 {
     return(new CertificateRequestRecordModel {
         RequestId = RequestId,
         EntityId = EntityId,
         Type = Type,
         State = State,
         GroupId = GroupId,
         Submitted = Submitted?.ToServiceModel(),
         Accepted = Accepted?.ToServiceModel(),
         Approved = Approved?.ToServiceModel(),
         ErrorInfo = ErrorInfo
     });
 }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Submitted != null)
     {
         Submitted.Validate();
     }
     if (Approved != null)
     {
         Approved.Validate();
     }
     if (Accepted != null)
     {
         Accepted.Validate();
     }
 }
Ejemplo n.º 12
0
        public async Task SubmitCertificate_Using_StandardReference()
        {
            // arrange
            var submitCertificate = new SubmitCertificateRequest {
                Uln = 9876543210, FamilyName = "Blogs", StandardReference = "1"
            };

            var certificateData = Builder <CertificateData> .CreateNew().With(cd => cd.CertificateReference = "DRAFT CERTIFICATE")
                                  .With(cd => cd.Standard        = Builder <Standard> .CreateNew().With(s => s.StandardCode = null).With(s => s.StandardReference = "1").Build())
                                  .With(cd => cd.Learner         = Builder <Learner> .CreateNew().Build())
                                  .With(cd => cd.LearningDetails = Builder <LearningDetails> .CreateNew().Build())
                                  .With(cd => cd.PostalContact   = Builder <PostalContact> .CreateNew().Build())
                                  .Build();

            var status = new Status {
                CurrentStatus = "Submitted"
            };
            var created = new Created {
                CreatedAt = DateTime.UtcNow.AddHours(-1), CreatedBy = "Test"
            };
            var submitted = new Submitted {
                SubmittedAt = DateTime.UtcNow, SubmittedBy = "Test"
            };

            var certificate = new Certificate {
                CertificateData = certificateData, Status = status, Created = created, Submitted = submitted
            };

            var expectedResponse = new List <SubmitCertificateResponse>
            {
                new SubmitCertificateResponse {
                    Certificate = certificate
                }
            };

            _MockHttp.When(HttpMethod.Post, $"{apiBaseAddress}/api/v1/certificate/submit")
            .Respond(HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(expectedResponse));

            // act
            var actual = await _ApiClient.SubmitCertificates(new List <SubmitCertificateRequest> {
                submitCertificate
            });

            // assert
            Assert.That(actual, Has.Count.EqualTo(1));
            Assert.That(actual.First().ValidationErrors, Has.Count.EqualTo(0));
            Assert.That(actual.First().Certificate, Is.EqualTo(expectedResponse.First().Certificate));
        }
        public async Task Then_a_CreateIncentiveCommand_is_published_for_eligible_apprenticeships(
            bool withdrawnByEmployer, bool withdrawnByCompliance, bool hasEligibleEmploymentStartDate, bool accepted)
        {
            //Arrange
            var apprenticeship = _fixture.Create <ApprenticeshipModel>();

            apprenticeship.WithdrawnByEmployer            = withdrawnByEmployer;
            apprenticeship.WithdrawnByCompliance          = withdrawnByCompliance;
            apprenticeship.HasEligibleEmploymentStartDate = hasEligibleEmploymentStartDate;

            var model = _fixture.Build <IncentiveApplicationModel>()
                        .With(x => x.ApprenticeshipModels,
                              new List <ApprenticeshipModel> {
                apprenticeship
            }).Create();

            var @event = new Submitted(model);

            //Act
            await _sut.Handle(@event);

            //Assert
            if (accepted)
            {
                _mockCommandPublisher.Verify(m => m.Publish(It.Is <CreateIncentiveCommand>(i =>
                                                                                           i.AccountId == @event.Model.AccountId &&
                                                                                           i.AccountLegalEntityId == @event.Model.AccountLegalEntityId &&
                                                                                           i.IncentiveApplicationApprenticeshipId == apprenticeship.Id &&
                                                                                           i.ApprenticeshipId == apprenticeship.ApprenticeshipId &&
                                                                                           i.FirstName == apprenticeship.FirstName &&
                                                                                           i.LastName == apprenticeship.LastName &&
                                                                                           i.DateOfBirth == apprenticeship.DateOfBirth &&
                                                                                           i.Uln == apprenticeship.ULN &&
                                                                                           i.PlannedStartDate == apprenticeship.PlannedStartDate &&
                                                                                           i.ApprenticeshipEmployerTypeOnApproval == apprenticeship.ApprenticeshipEmployerTypeOnApproval &&
                                                                                           i.Phase == apprenticeship.Phase
                                                                                           ), It.IsAny <CancellationToken>()), Times.Once);
            }
            else
            {
                _mockCommandPublisher.Verify(m => m.Publish(It.Is <CreateIncentiveCommand>(i =>
                                                                                           i.IncentiveApplicationApprenticeshipId == apprenticeship.Id
                                                                                           ), It.IsAny <CancellationToken>()), Times.Never);
            }
        }
Ejemplo n.º 14
0
        public override void HandleInput(InputContext input)
        {
            if (!IsFocused)
            {
                return;
            }
            if (input.Manager.IsKeyHit(Key.Enter))
            {
                Submitted?.Invoke(text);
                return;
            }
            if (input.Manager.IsKeyHit(Key.BackSpace) && cursorPosition > 0)
            {
                text = text.Substring(0, cursorPosition - 1) + text.Substring(cursorPosition);
                cursorPosition--;
            }
            if (input.Manager.IsKeyPressed(Key.Left) && cursorPosition > 0)
            {
                cursorPosition--;
            }
            if (input.Manager.IsKeyPressed(Key.Right) && cursorPosition < text.Length)
            {
                cursorPosition++;
            }
            if (input.Manager.IsKeyPressed(Key.Home))
            {
                cursorPosition = 0;
            }
            if (input.Manager.IsKeyPressed(Key.End))
            {
                cursorPosition = text.Length;
            }

            foreach (var c in input.State.PressedCharacters)
            {
                if ((c < '0' || c > '9') && (c < '@' || c > 'Z') && (c < 'a' || c > 'z') && !allowedChars.Contains(c))
                {
                    continue;
                }

                text = text.Substring(0, cursorPosition) + c + text.Substring(cursorPosition);
                cursorPosition++;
            }
        }
Ejemplo n.º 15
0
        public async Task GetCertificate()
        {
            // arrange
            long   uln                  = 1234567890;
            string lastname             = "Bloggs";
            string standard             = "1";
            string certificateReference = "123456790";

            var certificateData = Builder <CertificateData> .CreateNew().With(cd => cd.CertificateReference = certificateReference)
                                  .With(cd => cd.Standard        = Builder <Standard> .CreateNew().With(s => s.StandardCode = 1).Build())
                                  .With(cd => cd.Learner         = Builder <Learner> .CreateNew().Build())
                                  .With(cd => cd.LearningDetails = Builder <LearningDetails> .CreateNew().Build())
                                  .With(cd => cd.PostalContact   = Builder <PostalContact> .CreateNew().Build())
                                  .Build();

            var status = new Status {
                CurrentStatus = "Submitted"
            };
            var created = new Created {
                CreatedAt = DateTime.UtcNow.AddHours(-1), CreatedBy = "Test"
            };
            var submitted = new Submitted {
                SubmittedAt = DateTime.UtcNow, SubmittedBy = "Test"
            };

            var expectedResponse = new Certificate {
                CertificateData = certificateData, Status = status, Created = created, Submitted = submitted
            };

            _MockHttp.When(HttpMethod.Get, $"{apiBaseAddress}/api/v1/certificate/{uln}/{lastname}/{standard}")
            .Respond(HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(expectedResponse));

            // act
            var request = new GetCertificateRequest {
                Uln = uln, FamilyName = lastname, Standard = standard
            };
            var actual = await _ApiClient.GetCertificate(request);

            // assert
            Assert.That(actual.Error, Is.Null);
            Assert.That(actual.Certificate, Is.Not.Null);
        }
Ejemplo n.º 16
0
 protected override void Awake()
 {
     TextWidget.Submitted += text => Submitted?.Invoke(text);
 }
 /// <summary>
 /// Called when [submitted].
 /// </summary>
 /// <param name="e">The e.</param>
 protected virtual void OnSubmitted(SubmitEventArgs <TEntity> e) => Submitted?.Invoke(this, e);
Ejemplo n.º 18
0
 protected void OnSubmit() => Submitted?.Invoke(Text);
Ejemplo n.º 19
0
 void ICommandPatternObserver <TSpec> .OnCommandSubmitted(ICommandSubmission <TSpec> submission)
 => Submitted?.Invoke(submission);
Ejemplo n.º 20
0
 public void Submit() => Submitted?.Invoke(this, EventArgs.Empty);
Ejemplo n.º 21
0
 void ICommandPatternObserver.OnCommandSubmitted(ICommandSubmission submission)
 => Submitted?.Invoke((ICommandSubmission <TSpec>)submission);
 public static IEnumerable <ApprenticeshipModel> EligibleApprenticeships(this Submitted @event)
 {
     return(@event.Model.ApprenticeshipModels.Where(a => !a.WithdrawnByEmployer && !a.WithdrawnByCompliance));
 }
Ejemplo n.º 23
0
        public async Task Then_a_CreateIncentiveCommand_is_not_published_for_withdrawn_apprenticeships()
        {
            //Arrange
            var apprenticeships = _fixture.CreateMany <ApprenticeshipModel>(7).ToList();

            apprenticeships[0].WithdrawnByEmployer   = true;
            apprenticeships[0].WithdrawnByCompliance = false;

            apprenticeships[1].WithdrawnByEmployer   = false;
            apprenticeships[1].WithdrawnByCompliance = false;

            apprenticeships[2].WithdrawnByEmployer   = false;
            apprenticeships[2].WithdrawnByCompliance = false;

            apprenticeships[3].WithdrawnByEmployer   = true;
            apprenticeships[3].WithdrawnByCompliance = false;

            apprenticeships[4].WithdrawnByEmployer   = true;
            apprenticeships[4].WithdrawnByCompliance = false;

            apprenticeships[5].WithdrawnByEmployer   = false;
            apprenticeships[5].WithdrawnByCompliance = true;

            apprenticeships[6].WithdrawnByEmployer   = false;
            apprenticeships[6].WithdrawnByCompliance = true;

            var model = _fixture.Build <IncentiveApplicationModel>()
                        .With(x => x.ApprenticeshipModels, apprenticeships).Create();
            var @event = new Submitted(model);

            //Act
            await _sut.Handle(@event);

            //Assert
            foreach (var apprenticeship in @event.Model.ApprenticeshipModels.Where(a => a.WithdrawnByEmployer == false && a.WithdrawnByCompliance == false))
            {
                _mockCommandPublisher.Verify(m => m.Publish(It.Is <CreateIncentiveCommand>(i =>
                                                                                           i.AccountId == @event.Model.AccountId &&
                                                                                           i.AccountLegalEntityId == @event.Model.AccountLegalEntityId &&
                                                                                           i.IncentiveApplicationApprenticeshipId == apprenticeship.Id &&
                                                                                           i.ApprenticeshipId == apprenticeship.ApprenticeshipId &&
                                                                                           i.FirstName == apprenticeship.FirstName &&
                                                                                           i.LastName == apprenticeship.LastName &&
                                                                                           i.DateOfBirth == apprenticeship.DateOfBirth &&
                                                                                           i.Uln == apprenticeship.ULN &&
                                                                                           i.PlannedStartDate == apprenticeship.PlannedStartDate &&
                                                                                           i.ApprenticeshipEmployerTypeOnApproval == apprenticeship.ApprenticeshipEmployerTypeOnApproval
                                                                                           ), It.IsAny <CancellationToken>()), Times.Once);
            }

            foreach (var apprenticeship in @event.Model.ApprenticeshipModels.Where(a => a.WithdrawnByEmployer == true))
            {
                _mockCommandPublisher.Verify(m => m.Publish(It.Is <CreateIncentiveCommand>(i =>
                                                                                           i.IncentiveApplicationApprenticeshipId == apprenticeship.Id
                                                                                           ), It.IsAny <CancellationToken>()), Times.Never);
            }

            foreach (var apprenticeship in @event.Model.ApprenticeshipModels.Where(a => a.WithdrawnByCompliance == true))
            {
                _mockCommandPublisher.Verify(m => m.Publish(It.Is <CreateIncentiveCommand>(i =>
                                                                                           i.IncentiveApplicationApprenticeshipId == apprenticeship.Id
                                                                                           ), It.IsAny <CancellationToken>()), Times.Never);
            }
        }