public void RegistrationController_AddAddress_GET_Success() { //ARRANGE: //create a user who does exist in the db var user = new User { UserId = 1, EmailAddress = "*****@*****.**", EmailVerifiedDate = VirtualDateTime.Now }; var routeData = new RouteData(); routeData.Values.Add("Action", nameof(RegistrationController.AddAddress)); routeData.Values.Add("Controller", "Registration"); var controller = UiTestHelper.GetController <RegistrationController>(user.UserId, routeData, user); var orgModel = new OrganisationViewModel { ManualRegistration = false, ManualAddress = true, SectorType = SectorTypes.Public }; controller.StashModel(orgModel); //ACT: var result = controller.AddAddress() as ViewResult; var model = result?.Model as OrganisationViewModel; var stashedModel = controller.UnstashModel <OrganisationViewModel>(); //ASSERT: Assert.NotNull(result, "Expected ViewResult"); Assert.That(result.ViewName == nameof(RegistrationController.AddAddress), "Expected Viewname=AddAddress"); Assert.NotNull(model, "Expected model of OrganisationViewModel"); Assert.NotNull(stashedModel, "Expected model saved to stash"); Assert.That(model.ManualAddress, "Expected ManualAddress to be false"); }
public MethodResult Update(OrganisationViewModel organisationVM) { var methodResult = new MethodResult(); try { if (_organisationSearch.OrganisationNameDuplicate(organisationVM)) { methodResult.SuccessFaliure = Enums.MethodResultOutcome.Failure; methodResult.Message = string.Format("Organisation Name {0} already exists, please enter non-duplicate organisation name and retry", organisationVM.OrgName); return(methodResult); } if (_organisationSearch.OrganisationIdDuplicate(organisationVM)) { methodResult.SuccessFaliure = Enums.MethodResultOutcome.Failure; methodResult.Message = string.Format("Organisation id {0} already exists, please enter non-duplicate organisation id and retry", organisationVM.OrgId); return(methodResult); } _context.OrgList.Attach(_entityToViewModelMapper.MapOrganisationViewModelToEntity(organisationVM)).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); methodResult.SuccessFaliure = Enums.MethodResultOutcome.Success; methodResult.Message = "Organisation updated successfully"; } catch (Exception e) { methodResult.SuccessFaliure = Enums.MethodResultOutcome.Failure; methodResult.Message = "Error ocurred while updating organisation, please retry"; } return(methodResult); }
public bool OrganisationIdDuplicate(OrganisationViewModel organisationVM) { var resultSet = _context.OrgList.AsQueryable(); resultSet = resultSet.Where(x => (x.OrgPkId != organisationVM.OrgPkId) && (x.OrgId.Replace(" ", "") == organisationVM.OrgId.Replace(" ", ""))); return(resultSet.Any()); }
private async Task <ActionResult> PublishOrgansation(UcasProviderEnrichmentGetModel ucasProviderEnrichmentGetModel, string providerCode) { var providerSummary = await _manageApi.GetProviderSummary(providerCode); var enrichmentModel = ucasProviderEnrichmentGetModel.EnrichmentModel; var aboutAccreditingTrainingProviders = await MergeTrainingProviderViewModels(providerCode, enrichmentModel); var model = OrganisationViewModel.FromEnrichmentModel(ucasProviderEnrichmentGetModel, aboutAccreditingTrainingProviders, providerSummary); ValidateModelForPublication(model); if (!ModelState.IsValid) { return(View("Details", model)); } else { var result = await _manageApi.PublishAllCoursesOfProviderToSearchAndCompare(providerCode); if (result) { TempData["MessageType"] = "success"; TempData["MessageTitle"] = "Your changes have been published – this content will appear on all of your course pages"; return(RedirectToAction("Details", new { providerCode = providerCode })); } else { // This is a no ops, there should not be any viable valid reason that api rejects, hence dead end. throw new InvalidOperationException("attempting to publish nonexistent organisation enrichment: " + providerCode); } } }
public ActionResult Details(int id) { itemManager = new ItemManager(); userManager = new UserManager(); subManager = new SubscriptionManager(); Item org = itemManager.GetOrganisationWithDetails(id); if (org == null) { return(HttpNotFound()); } Item subbedItem = subManager.GetSubscribedItemsForUser(User.Identity.GetUserId()) .FirstOrDefault(i => i.ItemId == org.ItemId); OrganisationViewModel organisationViewModel = Mapper.Map(org, new OrganisationViewModel()); organisationViewModel.User = User.Identity.IsAuthenticated ? userManager.GetUser(User.Identity.GetUserId()) : null; organisationViewModel.Organisation = Mapper.Map(org, new ItemDTO()); organisationViewModel.Subscribed = subbedItem != null; organisationViewModel.MemberList = GetOrgMembers(org); //Log visit actitivy new SubplatformManager().LogActivity(ActivityType.VisitActitiy); //Assembling the view return(View(organisationViewModel)); }
public ViewResult View(int organisationID) { var organisation = organisationRepository.GetById(organisationID); var vm = new OrganisationViewModel(organisation); return(View(vm)); }
public async Task <IActionResult> UpdateOrganisation(OrganisationViewModel model) { if (!ModelState.IsValid) { return(View("Organisation", model)); } var organisation = new Organisation { PartyId = model.PartyId, OrganisationName = model.OrganisationName, TradingName = model.TradingName }; if (model.PartyId > 0) { await _partyRespository.UpdateOrganisation(organisation); } else { await _partyRespository.AddOrganisation(organisation); } return(RedirectToAction("Index", "Home")); }
public ActionResult Add(OrganisationViewModel model) { if (!ModelState.IsValid) { return(View(model)); } if (!model.EmaiClient.Contains("@outlook.com")) { this.ModelState.AddModelError("", OrganisationTr.EmailMustBeOutlook); return(View(model)); } //Check is there another organisation with the same name if (this.organisationService.IsExist(model.Name)) { this.ModelState.AddModelError("", OrganisationTr.OrganisationExist); return(View(model)); } this.organisationService.Add( new Organisation { Name = model.Name, Address = model.Address, EmailClient = model.EmaiClient, EmailClientPassword = KAssets.Controllers.StaticFunctions.RSAALg.Encryption(model.EmailClientPassword) }); return(Redirect("/Admin/Organisation/GetAll")); }
public MethodResult Create(OrganisationViewModel organisationVM) { var methodResult = new MethodResult(); try { if (_organisationSearch.OrganisationNameDuplicate(organisationVM)) { methodResult.SuccessFaliure = Enums.MethodResultOutcome.Failure; methodResult.Message = string.Format("Organisation {0} already exists, please enter non-duplicate organisation name and retry", organisationVM.OrgName); return(methodResult); } if (_organisationSearch.OrganisationIdDuplicate(organisationVM)) { methodResult.SuccessFaliure = Enums.MethodResultOutcome.Failure; methodResult.Message = string.Format("Organisation Id {0} already exists, please enter non-duplicate organisation id and retry", organisationVM.OrgId); return(methodResult); } _context.OrgList.Add(_entityToViewModelMapper.MapOrganisationViewModelToEntity(organisationVM)); _context.SaveChanges(); methodResult.SuccessFaliure = Enums.MethodResultOutcome.Success; } catch (Exception e) { methodResult.SuccessFaliure = Enums.MethodResultOutcome.Failure; string errorMessage = "Error ocurred while creating organisation, please retry"; methodResult.Message = errorMessage; } return(methodResult); }
public virtual async Task <OrganisationViewModel> CreateOrganisationViewModelAsync( EnterCodesViewModel enterCodes, User currentUser) { var org = await _organisationBusinessLogic.GetOrganisationByEmployerReferenceAndSecurityCodeAsync( enterCodes.EmployerReference, enterCodes.SecurityToken); if (org == null) { return(null); } var model = new OrganisationViewModel(); // when SecurityToken is expired then model.SecurityCodeExpired should be true model.IsSecurityCodeExpired = org.HasSecurityCodeExpired(); model.Employers = new PagedResult <EmployerRecord>(); model.Employers.Results = new List <EmployerRecord> { _organisationBusinessLogic.CreateEmployerRecord(org) }; model.SelectedEmployerIndex = 0; //Mark the organisation as authorised model.SelectedAuthorised = true; model.IsFastTrackAuthorised = true; return(model); }
public void GetWorkflowStatus_Blank() { var model = new OrganisationViewModel(); var status = model.GetWorkflowStatus(); Assert.AreEqual(status, GovUk.Education.ManageCourses.Ui.ViewModels.Enums.WorkflowStatus.Blank); }
public async Task <ActionResult> DetailsPost(string providerCode, OrganisationViewModel model) { var ucasProviderEnrichmentGetModel = await _manageApi.GetProviderEnrichment(providerCode); var result = await PublishOrgansation(ucasProviderEnrichmentGetModel, providerCode); return(result); }
public void a_blank_model_is_invalid() { model = new OrganisationViewModel(); model.Validate(); Assert.IsFalse(model.IsValid); }
public void ToTableModel(TblOrganisation ToReturn, OrganisationViewModel Model) { ToReturn.Name = Model.Name; ToReturn.Address = Model.Address; ToReturn.Contact = Model.Contact; ToReturn.ContactEmail = Model.ContactEmail; ToReturn.ContactNo = Model.ContactNo; }
public void RegistrationController_AddContact_POST_NotManualRegistration_RedirectToConfirmOrganisation() { //ARRANGE: var user = new User { UserId = 1, EmailAddress = "*****@*****.**", EmailVerifiedDate = VirtualDateTime.Now }; var routeData = new RouteData(); routeData.Values.Add("Action", nameof(RegistrationController.AddContact)); routeData.Values.Add("Controller", "Registration"); var controller = UiTestHelper.GetController <RegistrationController>(1, routeData, user); var model = new OrganisationViewModel { OrganisationName = "Acme ltd", Address1 = "123", Address3 = "WestMinster", Postcode = "W1A 2ED", SelectedEmployerIndex = 0, SearchText = "smith", ManualRegistration = false, ManualAddress = true, SectorType = SectorTypes.Public, SicCodes = new List <int>(), ManualEmployers = new List <EmployerRecord>() }; controller.StashModel(model); OrganisationViewModel savedModel = model.GetClone(); savedModel.ContactEmailAddress = "[email protected]"; savedModel.ContactFirstName = "test firstName2"; savedModel.ContactLastName = "test lastName2"; savedModel.ContactJobTitle = "test job title2"; savedModel.ContactPhoneNumber = "79004 123 456"; controller.Bind(savedModel); //Set the expected model OrganisationViewModel expectedModel = model.GetClone(); expectedModel.ConfirmReturnAction = nameof(RegistrationController.AddContact); //ACT: //2.Run and get the result of the test var result = controller.AddContact(model) as RedirectToActionResult; var unstashedModel = controller.UnstashModel <OrganisationViewModel>(); //ASSERT: Assert.NotNull(result, "Expected RedirectToActionResult", "Wrong redirect"); Assert.That(result.ActionName == nameof(RegistrationController.ConfirmOrganisation), "Redirected to the wrong action"); Assert.NotNull(unstashedModel, "Expected Stashed OrganisationViewModel"); //Check result is same as expected expectedModel.Compare(unstashedModel); }
public void RegisterController_ReviewRequest_POST_ManualRegistration_ServiceActivated() { //ARRANGE: //create a user who does exist in the db var user = new User { UserId = 1, EmailAddress = "*****@*****.**", EmailVerifiedDate = VirtualDateTime.Now }; var org = new Organisation { OrganisationId = 1, SectorType = SectorTypes.Private, Status = OrganisationStatuses.Pending }; //TODO: Refactoring to user the same Helpers (ie AddScopeStatus.AddScopeStatus) org.OrganisationScopes.Add( new OrganisationScope { Organisation = org, ScopeStatus = ScopeStatuses.InScope, SnapshotDate = org.SectorType.GetAccountingStartDate(VirtualDateTime.Now.Year), Status = ScopeRowStatuses.Active }); var address = new OrganisationAddress { AddressId = 1, OrganisationId = 1, Organisation = org, Status = AddressStatuses.Pending }; var userOrg = new UserOrganisation { UserId = 1, OrganisationId = 1, AddressId = address.AddressId, Address = address, User = user, Organisation = org }; var routeData = new RouteData(); routeData.Values.Add("Action", "OrganisationType"); routeData.Values.Add("Controller", "Register"); var controller = UiTestHelper.GetController <RegisterController>(user.UserId, routeData, user, org, address, userOrg); var model = new OrganisationViewModel { ReviewCode = userOrg.GetReviewCode() }; controller.StashModel(model); //ACT: var result = controller.ReviewRequest(model, "approve") as RedirectToActionResult; //ASSERT: Assert.That(result != null, "Expected RedirectToActionResult"); Assert.That(result.ActionName == "RequestAccepted", "Expected redirect to RequestAccepted"); Assert.That(userOrg.PINConfirmedDate > DateTime.MinValue); Assert.That(userOrg.Organisation.Status == OrganisationStatuses.Active); Assert.That(userOrg.Organisation.GetLatestAddress().AddressId == address.AddressId); Assert.That(address.Status == AddressStatuses.Active); }
public async Task <int> Update(OrganisationViewModel viewModel) { var model = await _viewModelToModelConverter.Convert(viewModel); _unitOfWork.Organisations.Update(model); await _unitOfWork.SaveChangesAsync(); return(model.Id); }
public AdminLicenceViewModel() { Licence = new LicenceApplicationViewModel(); OrganisationDetails = new OrganisationDetailsViewModel(); PrincipalAuthority = new PrincipalAuthorityViewModel(); AlternativeBusinessRepresentatives = new AlternativeBusinessRepresentativeCollectionViewModel(); DirectorsOrPartners = new DirectorOrPartnerCollectionViewModel(); NamedIndividuals = new NamedIndividualCollectionViewModel(); Organisation = new OrganisationViewModel(); }
// GET: Me/Organisation public ActionResult Index() { OrganisationViewModel ViewModel = new OrganisationViewModel(); ViewModel.Organisations = db.Organisations.Where(x => x.AspNetUsers.Any(y => y.UserName == User.Identity.Name)).ToList(); ViewModel.Registrars = new SelectList(db.CorporateRegistrars, "Id", "Name"); ViewModel.States = new SelectList(db.States, "Id", "Name"); ViewModel.LGAs = new SelectList(db.LGAs.Take(30), "Id", "Name"); return(View(ViewModel)); }
public IActionResult OnGet(int id) { Organisation = _organisation.GetOrganisationDetail(id); if (Organisation == null) { return(NotFound()); } return(Page()); }
public OrganisationViewModel ToViewModel(TblOrganisation Model) { OrganisationViewModel ToReturn = new OrganisationViewModel(); ToReturn.Address = Model.Address; ToReturn.Contact = Model.Contact; ToReturn.ContactEmail = Model.ContactEmail; ToReturn.ContactNo = Model.ContactNo; ToReturn.Name = Model.Name; return(ToReturn); }
public async Task Index_UpdateOrganisationPostWithInvalidModelReturnsView() { var model = new OrganisationViewModel(); _controller.ModelState.AddModelError("", "invalid model"); var result = await _controller.UpdateOrganisation(model); Assert.IsTrue(result is ViewResult); Assert.AreSame(model, (result as ViewResult).Model); }
public ActionResult Details(int id) { var organisation = this.organisationService.GetById(id); var viewModel = new OrganisationViewModel { Id = organisation.Id, Name = organisation.Name, Address = organisation.Address }; return(View(viewModel)); }
public void TestCreateOrganisationView() { OrganisationViewModel organisation = new OrganisationViewModel() { Name = "Maarten's Songs" }; RedirectToRouteResult viewResult = (RedirectToRouteResult)_organisationsController.Create(organisation, null); Organisation createdOrganisation = _organisationManager.ReadOrganisation("Maarten's Songs"); Assert.AreEqual("Details/" + createdOrganisation.Id, viewResult.RouteValues["action"]); }
public void GetWorkflowStatus_InitialDraft() { var model = new OrganisationViewModel { TrainWithDisability = "TrainWithDisability", TrainWithUs = "TrainWithUs" }; var status = model.GetWorkflowStatus(); Assert.AreEqual(status, GovUk.Education.ManageCourses.Ui.ViewModels.Enums.WorkflowStatus.InitialDraft); }
public TblOrganisation ToTableModel(OrganisationViewModel Model) { TblOrganisation ToReturn = new TblOrganisation(); ToReturn.ID = Guid.Parse(Model.Id); ToReturn.ApplicationUserId = Guid.Parse(Model.ApplicationUserId); ToReturn.Name = Model.Name; ToReturn.Address = Model.Address; ToReturn.Contact = Model.Contact; ToReturn.ContactEmail = Model.ContactEmail; ToReturn.ContactNo = Model.ContactNo; return(ToReturn); }
public IActionResult Change(OrganisationViewModel organisationVm) { var reportViewModel = new ReportViewModel { Report = _reportService.GetReport(_currentPeriod.PeriodString, EmployerAccount.AccountId) }; reportViewModel.Report.OrganisationName = organisationVm.Report.OrganisationName; _reportService.SaveReport(reportViewModel.Report, _userService.GetUserModel(User)); return(new RedirectResult(Url.Action("Edit", "Report"))); }
public async Task <IActionResult> Create([Bind("Name,Contact,ContactEmail,ContactNo,Address,ApplicationUserId")] OrganisationViewModel FromView) { if (ModelState.IsValid) { FromView.Id = Guid.NewGuid().ToString(); TblOrganisation result = OrgDTO.ToTableModel(FromView); _context.Organisations.Add(result); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(FromView)); }
public void GetWorkflowStatus_BlankSubsequentDraft() { var model = new OrganisationViewModel { TrainWithDisability = "", TrainWithUs = "", Status = EnumStatus.Draft, LastPublishedTimestampUtc = DateTime.Now }; var status = model.GetWorkflowStatus(); Assert.AreEqual(status, GovUk.Education.ManageCourses.Ui.ViewModels.Enums.WorkflowStatus.BlankSubsequentDraft); }
public void Index() { var _OrganisationLogic = new Mock <ILogicRepository <OrganisationModel> >(); var testdata = new OrganisationModel { Id = 3, OrganisationName = "My Test Class Organisation" }; _OrganisationLogic.Setup(p => p.GetOrganisation()).Returns(testdata); HomeController controller = new HomeController(_OrganisationLogic.Object); ViewResult result = controller.Index() as ViewResult; OrganisationViewModel model = (OrganisationViewModel)result.Model; Assert.AreEqual(testdata.OrganisationName, model.OrganisationName); }