Пример #1
0
        public async Task <IActionResult> ConfirmStandard(StandardViewModel model, Guid id, int standardCode)
        {
            var application = await _apiClient.GetApplication(id);

            if (!CanUpdateApplicationAsync(application))
            {
                return(RedirectToAction("Applications", "Application"));
            }

            var standards = await _apiClient.GetStandards();

            model.SelectedStandard  = standards.FirstOrDefault(s => s.StandardId == standardCode);
            model.ApplicationStatus = await ApplicationStandardStatus(application, standardCode);

            if (!model.IsConfirmed)
            {
                ModelState.AddModelError(nameof(model.IsConfirmed), "Please tick to confirm");
                TempData["ShowErrors"] = true;
                return(View("~/Views/Application/Standard/ConfirmStandard.cshtml", model));
            }

            if (!string.IsNullOrEmpty(model.ApplicationStatus))
            {
                return(View("~/Views/Application/Standard/ConfirmStandard.cshtml", model));
            }

            await _apiClient.UpdateStandardData(id, standardCode, model.SelectedStandard?.ReferenceNumber, model.SelectedStandard.Title);

            return(RedirectToAction("SequenceSignPost", "Application", new { Id = id }));
        }
 private void LoadData()
 {
     AsyncWorker.Execute(() =>
     {
         var result = new List <StandardViewModel>();
         for (var counter = 1; counter <= 100; counter++)
         {
             var customer = new StandardViewModel
             {
                 Text1 = GetRandomFirstName() + " " + GetRandomLastName(),
                 Text2 = GetRandomCompany()
             };
             result.Add(customer);
         }
         Thread.Sleep(2000); // Simulating a slow process
         return(result);
     }, result =>
     {
         Customers.Clear();
         foreach (var subscriber in result)
         {
             subscriber.LoadSharedImage1FromBrushResource("CODE.Framework-Icon-Contact2");
             Customers.Add(subscriber);
         }
     }, this);
 }
Пример #3
0
        public void ShouldShowEquivalentLevel()
        {
            var detail = new Standard();
            var model  = new StandardViewModel
            {
                Level = 6
            };
            var model2 = new StandardViewModel
            {
                Level = 4
            };
            var model3 = new StandardViewModel
            {
                Level = 8
            };

            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "dd", 1).Should().Contain("bachelor's degree");

            html = detail.RenderAsHtml(model2).ToAngleSharp();
            GetPartial(html, "dd", 1).Should().Contain("certificate of higher education");

            html = detail.RenderAsHtml(model3).ToAngleSharp();
            GetPartial(html, "dd", 1).Should().Contain("doctorate");
        }
Пример #4
0
        public IActionResult Index(Guid id)
        {
            var standardViewModel = new StandardViewModel {
                Id = id
            };

            return(View("~/Views/Application/Standard/FindStandard.cshtml", standardViewModel));
        }
Пример #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var vm = new StandardViewModel(UserDialogs.Instance);

            btnAlert.TouchUpInside     += (sender, e) => vm.Alert.Execute(null);
            btnAlertLong.TouchUpInside += (sender, e) => vm.AlertLongText.Execute(null);
        }
        private void ProcessViewModel(StandardViewModel viewModel, List <FundingPeriod> fundingPeriods, DateTime?effectiveFrom, string ukprn)
        {
            viewModel.FindApprenticeshipTrainingText = _buttonTextService.GetFindTrainingProvidersText(HttpContext);
            var nextFundingCap = _fundingBandService.GetNextFundingPeriodWithinTimePeriod(fundingPeriods, effectiveFrom, _nextFundingPeriodMessageCutoffMonths);

            viewModel.NextEffectiveFrom = nextFundingCap?.EffectiveFrom;
            viewModel.NextFundingCap    = nextFundingCap?.FundingCap;
            viewModel.Ukprn             = ukprn;
        }
Пример #7
0
        public void ShouldNotShowOrganisationDetailsWhenAssessmentOrganisationsAreNull()
        {
            var detail = new Standard();
            var model  = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = null
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#organisation-name").Should().BeEmpty();
        }
Пример #8
0
        public void ShouldShowMoreInformation()
        {
            var detail = new Standard();
            var model  = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = new List <AssessmentOrganisation>()
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#more-information").Should().Contain("Institute for Apprenticeships and Technical Education has more detailed information");
        }
Пример #9
0
        public ActionResult Add(decimal ItemId, decimal CategoryId)
        {
            ViewBag.Title       = Resources.PageTitle.Standard_Add;
            ViewBag.PageBar     = GetPageBar(Resources.PageTitle.Standard_Add);
            ViewBag.Description = "";
            var model = new StandardViewModel();

            model.Publish    = true;
            model.ItemId     = ItemId;
            model.CategoryId = CategoryId;
            return(View(model));
        }
Пример #10
0
        public void ShouldShowNoEndPointAssessment()
        {
            var detail = new Standard();
            var model  = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = new List <AssessmentOrganisation>()
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#no-assessment-organisations").Should().Contain("There are no end-point assessment");
        }
Пример #11
0
        public async Task <IActionResult> Search(StandardViewModel model)
        {
            if (string.IsNullOrEmpty(model.StandardToFind) || model.StandardToFind.Length <= 2)
            {
                ModelState.AddModelError(nameof(model.StandardToFind), "Enter a valid search string (more than 2 characters)");
                TempData["ShowErrors"] = true;
                return(RedirectToAction(nameof(Index), new { model.Id }));
            }

            var standards = await _apiClient.GetStandards();

            model.Results = standards.Where(s => s.Title.Contains(model.StandardToFind, StringComparison.InvariantCultureIgnoreCase)).ToList();

            return(View("~/Views/Application/Standard/FindStandardResults.cshtml", model));
        }
Пример #12
0
        public IActionResult ComplexModelData()
        {
            var model = new StandardViewModel()
            {
                Id        = "complex",
                Name      = "Complex",
                ParentId  = "root",
                Target    = "",
                View      = "complex",
                ModelData = @"{ ""Item1"":{ ""Copy"":""<p>Item 1 copy</p>""}, ""Copy"":""<p>Standard copy</p>""}",
                Children  = new List <IViewModel>()
            };

            //send the model to the standard view
            return(View(model));
        }
Пример #13
0
        public void ShouldShowEndPointAssessmentName()
        {
            var detail = new Standard();
            var model  = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = new List <AssessmentOrganisation> {
                    new AssessmentOrganisation {
                        Name = "organisation 1"
                    }
                }
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".organisation-name").Should().Be("organisation 1");
        }
Пример #14
0
        public void ShouldNotShowNoEndPointAssessmentIOrganisationsPresent()
        {
            var detail = new Standard();
            var model  = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = new List <AssessmentOrganisation> {
                    new AssessmentOrganisation {
                        Name = "organisation 1"
                    }
                }
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, "#no-assessment-organisations").Should().BeEmpty();
        }
Пример #15
0
        public void ShouldShowEndPointAssessmentEmail()
        {
            var detail = new Standard();
            var email  = "*****@*****.**";
            var model  = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = new List <AssessmentOrganisation> {
                    new AssessmentOrganisation {
                        Email = email
                    }
                }
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".email").Should().Be(email);
        }
Пример #16
0
        public JsonResult Edit(StandardViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (_standardService.IsStanderdWeightSumGreaterItem(model.CategoryId, model.ItemId, model.Id, model.Weight))
                {
                    return(Json(new { data = model, success = false, ErrorsList = new string[] { Resources.LocalizedText.IsStanderdWeightSumGreaterItem } }, JsonRequestBehavior.AllowGet));
                }
                var StandardEntity = _standardService.GetById(model.Id);
                StandardEntity = Mapper.Map(model, StandardEntity);
                _standardService.Edit(StandardEntity);
                return(Json(new { data = model, success = true }, JsonRequestBehavior.AllowGet));
            }
            var errors = ModelState.GetDistinctModelErrors();

            return(Json(new { data = model, success = false, ErrorsList = errors }, JsonRequestBehavior.AllowGet));
        }
Пример #17
0
        public void ShouldShowEndPointAssessmentPhoneNumber()
        {
            var detail      = new Standard();
            var phoneNumber = "12345";
            var model       = new StandardViewModel
            {
                Level = 6,
                AssessmentOrganisations = new List <AssessmentOrganisation> {
                    new AssessmentOrganisation {
                        Phone = phoneNumber
                    }
                }
            };
            var html = detail.RenderAsHtml(model).ToAngleSharp();

            GetPartial(html, ".phone-number").Should().Be(phoneNumber);
        }
        public void ShouldReturnViewModelWhenAssessmentOrgsEntityNotFound()
        {
            var viewModel = new StandardViewModel();
            var response  = new GetStandardResponse {
                StatusCode = GetStandardResponse.ResponseCodes.AssessmentOrgsEntityNotFound
            };

            _mockMediator.Setup(x => x.Send(It.IsAny <GetStandardQuery>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);
            _mockMappingService.Setup(m => m.Map <GetStandardResponse, StandardViewModel>(response))
            .Returns(viewModel);

            var result = _sut.Standard("2", "test").Result as ViewResult;

            result.Should().NotBeNull();
            result.Model.Should().Be(viewModel);
        }
Пример #19
0
        public JsonResult Add(StandardViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (_standardService.IsStanderdWeightSumGreaterItem(model.CategoryId, model.ItemId, model.Id, model.Weight))
                {
                    return(Json(new { data = model, success = false, ErrorsList = new string[] { Resources.LocalizedText.IsStanderdWeightSumGreaterItem } }, JsonRequestBehavior.AllowGet));
                }
                var EntityMapped = Mapper.Map <Standard>(model);
                EntityMapped.CreatedById = CurrentUser.Id;
                EntityMapped.CreatedDate = DateTime.Now;
                _standardService.Add(EntityMapped);
                return(Json(new { data = model, success = true }, JsonRequestBehavior.AllowGet));
            }
            var errors = ModelState.GetDistinctModelErrors();

            return(Json(new { data = model, success = false, ErrorsList = errors }, JsonRequestBehavior.AllowGet));
        }
Пример #20
0
        public async Task <IActionResult> ConfirmStandard(Guid id, int standardCode)
        {
            var application = await _apiClient.GetApplication(id);

            var standardViewModel = new StandardViewModel {
                Id = id, StandardCode = standardCode
            };

            if (!CanUpdateApplicationAsync(application))
            {
                return(RedirectToAction("Applications", "Application"));
            }

            var standards = await _apiClient.GetStandards();

            standardViewModel.SelectedStandard  = standards.FirstOrDefault(s => s.StandardId == standardCode);
            standardViewModel.ApplicationStatus = await ApplicationStandardStatus(application, standardCode);

            return(View("~/Views/Application/Standard/ConfirmStandard.cshtml", standardViewModel));
        }
        public void ShouldReturnStandard()
        {
            // Assign
            var response  = new GetStandardResponse();
            var viewModel = new StandardViewModel();

            _mockMediator.Setup(m => m.Send(It.IsAny <GetStandardQuery>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);

            _mockMappingService.Setup(m => m.Map <GetStandardResponse, StandardViewModel>(response))
            .Returns(viewModel);

            // Act
            var result = _sut.Standard("1", "test").Result as ViewResult;

            // Assert
            _mockMediator.Verify(m => m.Send(It.IsAny <GetStandardQuery>(), It.IsAny <CancellationToken>()));
            _mockMappingService.Verify(m => m.Map <GetStandardResponse, StandardViewModel>(response));

            result.Model.Should().Be(viewModel);
        }
Пример #22
0
        public ViewResult Index()
        {
            var userName = User.Identity.GetUserName();
            var xmlDB    = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject);

            String pageName;

            if (String.IsNullOrEmpty(userName))
            {
                pageName = "";
            }
            else
            {
                pageName = _context.Users.First(c => c.Name == userName).ActProject;
            }

            var viewModel = new StandardViewModel {
                PageName  = pageName,
                Standards = xmlDB.Standards
            };

            return(View(viewModel));
        }
        // POST api/<controller>
        public IHttpActionResult PostNewStudent(StandardViewModel student)
        {
            var context = new StudentContext();

            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data"));
            }

            /* var ctx = new StandardViewModel
             * {
             *  Name="Eswar Reddy Deva",
             *  StandardId=101,
             *
             *    Students = new List<StudentViewModel>()
             *    {
             *        new StudentViewModel
             *      {
             *        FirstName = "Deva",
             *        LastName = "Reddy",
             *        Id = 101,
             *        Address = new AddressViewModel()
             *        {
             *            Address1 = "Hyderabad2",
             *            Address2 = "CMG Palli2",
             *            City = "Kadapa2",
             *            State = "AP2",
             *            StudentId = 101
             *        }
             *       }
             *    }
             * };*/

            context.Students.Add(student);
            context.SaveChanges();
            return(Ok());
        }
Пример #24
0
 public StandardPage()
 {
     InitializeComponent();
     BindingContext = new StandardViewModel();
 }
Пример #25
0
        public IActionResult SimpleExample()
        {
            //create a simple model structure

            //create the root as a row_columns_3
            IViewModel row0 = new StandardViewModel()
            {
                Id        = "R0",
                Name      = "Layout",
                ParentId  = "",
                Target    = "",
                View      = "row_columns_3",
                ModelData = "{ Columns: [ { CssClass: 'left' }, { CssClass:'center' }, { CssClass: 'right' } ] }",
                Children  = new List <IViewModel>()
            };

            //add a cell_container for cell 0
            row0.Children.Add(new StandardViewModel()
            {
                Id        = "abc",
                Name      = "R0C0",
                ParentId  = "Layout",
                Target    = "column_0",
                View      = "container",
                ModelData = "{ CssClass: 'cell_container', Heading: { Type: 'h1', Text: 'Container 1!'}  }",
                Children  = new List <IViewModel>()
            });
            //add a cell_container for cell 1
            row0.Children.Add(new StandardViewModel()
            {
                Id        = "abc1",
                Name      = "R0C1",
                ParentId  = "Layout",
                Target    = "column_1",
                View      = "container",
                ModelData = "{ CssClass: 'cell_container', Heading: { Type: 'h1', Text: 'Container 2'}  }",
                Children  = new List <IViewModel>()
            });
            //add a cell_container for cell 2
            row0.Children.Add(new StandardViewModel()
            {
                Id        = "abc2",
                Name      = "R0C2",
                ParentId  = "Layout",
                Target    = "column_2",
                View      = "container",
                ModelData = "{ CssClass: 'cell_container', Heading: { Type: 'h1', Text: 'Container 3'}  }",
                Children  = new List <IViewModel>()
            });

            //add some content to cell 0
            row0.Children[0].Children.Add(new StandardViewModel()
            {
                Id        = "abc3",
                Name      = "Html",
                ParentId  = "R0C1",
                Target    = "",
                View      = "html",
                ModelData = @"{ ""Copy_1"":{ ""Copy"":""<p>Nested Copy</p>""}, ""Copy"":""<p>Lorem ipsum dolor sit amet consectetur adipiscing elit penatibus tincidunt, non tempus mi euismod lobortis aenean erat. Curabitur tellus sociis viverra leo purus, sapien eget cursus tempor posuere molestie, faucibus ut ridiculus laoreet. Eu eleifend sodales scelerisque felis dictumst blandit hendrerit, integer elementum eget per rhoncus velit aliquet, ligula facilisis nisl nam aptent porta.</p>""}",
                Children  = new List <IViewModel>()
            });
            //add some more content to cell 0
            row0.Children[0].Children.Add(new StandardViewModel()
            {
                Id        = "abc4",
                Name      = "Html",
                ParentId  = "R0C1",
                Target    = "",
                View      = "html",
                ModelData = @"{ ""Copy"":""<h2>A Second Item</h2><p>This is another para from a seperate child with a heading!</p>""}",
                Children  = new List <IViewModel>()
            });
            //add some more content to cell 1
            row0.Children[1].Children.Add(new StandardViewModel()
            {
                Id        = "abc5",
                Name      = "Html",
                ParentId  = "R0C2",
                Target    = "",
                View      = "html",
                ModelData = @"{ ""Copy"":""<p>Gravida condimentum blandit hendrerit bibendum per ante vitae venenatis taciti, molestie varius pharetra urna vestibulum est interdum risus cubilia, velit pellentesque pulvinar mollis fames nunc rhoncus duis. Habitant tempus pretium viverra suspendisse vivamus nibh leo himenaeos, accumsan metus suscipit sociosqu porttitor lacinia neque sed primis, curae porta sem aenean fringilla mattis fermentum. Et nunc varius placerat ullamcorper dis imperdiet proin posuere, enim hac lectus lacinia turpis montes scelerisque nulla tempus, fusce duis libero ridiculus metus congue dictumst.</p>""}",
                Children  = new List <IViewModel>()
            });
            //add an image to cell 2
            row0.Children[2].Children.Add(new StandardViewModel()
            {
                Id        = "abc6",
                Name      = "Image",
                ParentId  = "R0C3",
                Target    = "",
                View      = "html",
                ModelData = @"{ ""Copy"":""<p>Gravida condimentum blandit hendrerit bibendum per ante vitae venenatis taciti, molestie varius pharetra urna vestibulum est interdum risus cubilia, velit pellentesque pulvinar mollis fames nunc rhoncus duis. Habitant tempus pretium viverra suspendisse vivamus nibh leo himenaeos, accumsan metus suscipit sociosqu porttitor lacinia neque sed primis, curae porta sem aenean fringilla mattis fermentum. Et nunc varius placerat ullamcorper dis imperdiet proin posuere, enim hac lectus lacinia turpis montes scelerisque nulla tempus, fusce duis libero ridiculus metus congue dictumst.</p>""}",
                Children  = new List <IViewModel>()
            });

            //send the model to the standard view
            return(View(row0));
        }
Пример #26
0
        public bool?Show(
            object viewModel,
            WindowShowBehavior behavior = WindowShowBehavior.Dialog,
            object ownerViewModel       = null,
            Action onClosed             = null
            )
        {
            if (!TryGetView(viewModel, out FrameworkElement view, out Exception getViewException))
            {
                throw getViewException;
            }

            StandardViewModel libraryViewModel = viewModel as StandardViewModel;
            bool isLibraryViewModel            = libraryViewModel != null;

            if (isLibraryViewModel)
            {
                libraryViewModel.InvokeOnShowing();
            }

            Window window = GetWindow(viewModel, view);

            bool?viewModelCloseResult = null;
            bool closedByViewModel    = false;

            if (TryGetOwnerWindow(ownerViewModel, out Window ownerWindow))
            {
                window.Owner = ownerWindow;
            }

            if (isLibraryViewModel)
            {
                libraryViewModel.TryingToClose += (sender, r) =>
                {
                    closedByViewModel    = true;
                    viewModelCloseResult = r;
                    window.Close();
                };
            }

            window.Closing += (sender, e) => UnregisterActiveWindow(viewModel, sender as Window);
            window.Closed  += (sender, e) => (sender as Window).Owner = null;

            RegisterActiveWindow(viewModel, window);

            if (onClosed != null)
            {
                window.Closed += (sender, e) => onClosed.Invoke();
            }

            switch (behavior)
            {
            case WindowShowBehavior.Dialog:
                bool?result = window.ShowDialog();
                return(!closedByViewModel ? result : viewModelCloseResult);

            case WindowShowBehavior.Window:
                window.Show();
                return(null);

            default:
                throw new NotSupportedException($"Value {behavior} of enum {typeof(WindowShowBehavior)} is not handled");
            }
        }