public UserSettingsViewModel (IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, FeaturesService featuresService, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.AutofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); var entryBuilder = new CommonEEVMBuilderFactory <UserSettings>(this, Entity, UoW, navigation, autofacScope); WarehouseFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultWarehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); LeaderFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultLeader) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); ResponsiblePersonFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultResponsiblePerson) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); OrganizationFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultOrganization) .UseViewModelJournalAndAutocompleter <OrganizationJournalViewModel>() .UseViewModelDialog <OrganizationViewModel>() .Finish(); }
public StockBalanceJournalViewModel( IUnitOfWorkFactory unitOfWorkFactory, IInteractiveService interactiveService, INavigationManager navigation, ILifetimeScope autofacScope, FeaturesService featuresService) : base(unitOfWorkFactory, interactiveService, navigation) { AutofacScope = autofacScope; JournalFilter = Filter = AutofacScope.Resolve <StockBalanceFilterViewModel>( new TypedParameter(typeof(JournalViewModelBase), this)); var dataLoader = new ThreadDataLoader <StockBalanceJournalNode>(unitOfWorkFactory); dataLoader.AddQuery(ItemsQuery); DataLoader = dataLoader; CreateNodeActions(); UpdateOnChanges(typeof(WarehouseOperation), typeof(Nomenclature)); TabName = "Остатки по складу " + (featuresService.Available(WorkwearFeature.Warehouses) ? Filter.Warehouse?.Name : ""); Filter.PropertyChanged += (sender, e) => TabName = "Остатки по складу " + (featuresService.Available(WorkwearFeature.Warehouses) ? Filter.Warehouse?.Name : ""); }
public SubdivisionViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ITdiCompatibilityNavigation navigation, IValidator validator, ILifetimeScope autofacScope, FeaturesService featuresService ) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.navigation = navigation ?? throw new ArgumentNullException(nameof(navigation)); this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); var builder = new CommonEEVMBuilderFactory <Subdivision>(this, Entity, UoW, NavigationManager, autofacScope); EntryWarehouse = builder.ForProperty(x => x.Warehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); EntrySubdivisionViewModel = builder.ForProperty(x => x.ParentSubdivision) .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>() .UseViewModelDialog <SubdivisionViewModel>() .Finish(); NotifyConfiguration.Instance.BatchSubscribe(SubdivisionOperationChanged) .IfEntity <SubdivisionIssueOperation>() .AndWhere(x => x.Subdivision.Id == Entity.Id); }
public async System.Threading.Tasks.Task testFeaturesGetAsync() { var features = new List<Features> { new Features() { Id = "test1" }, new Features() { Id = "test2" }, }; var fakeRepositoryMock = new Mock<IFeaturesRepository>(); fakeRepositoryMock.Setup(x => x.GetAll()).ReturnsAsync(features); var featuresService = new FeaturesService(fakeRepositoryMock.Object); var resultFeatures = await featuresService.GetFeatures(); Xunit.Assert.Collection(resultFeatures, features => { Xunit.Assert.Equal("test1", features.Id); }, features => { Xunit.Assert.Equal("test2", features.Id); }); }
public async Task SetValueShouldRaiseOnFeatureUpdated() { // Arrange int calls = 0; InitializeFeaturesData(); var settings = new Settings { OnServerFeatureUpdated = _ => { calls++; } }; var featuresService = new FeaturesService(_db, settings); string newValue = "dark"; // Act var result = await featuresService.SetValue("Theme", newValue); // Assert calls.ShouldBe(1); }
public async System.Threading.Tasks.Task testFeaturesAddAsync() { var fakeRepository = Mock.Of<IFeaturesRepository>(); var featuresService = new FeaturesService(fakeRepository); var features = new Features() { Id = "test" }; await featuresService.AddAndSave(features); }
public IncomeDocDlg(int id) { Build(); AutofacScope = MainClass.AppDIContainer.BeginLifetimeScope(); UoWGeneric = UnitOfWorkFactory.CreateForRoot <Income> (id); featuresService = AutofacScope.Resolve <FeaturesService>(); sizeService = AutofacScope.Resolve <SizeService>(); ConfigureDlg(); }
// Contact Persons. public List <ProjectTypes_VM> FeaturesNames() { FeaturesService Service = new FeaturesService(); List <ProjectTypes_VM> FeaturesNames = Service.Find(new PagingParams { key = null, pageNum = "1", pageSize = "10" }); return(FeaturesNames); }
public StockAllWearDlg() { this.Build(); ComboWorks.ComboFillReference(comboObject, "warehouse", ComboWorks.ListMode.OnlyItems, true, "name"); AutofacScope = MainClass.AppDIContainer.BeginLifetimeScope(); featureService = AutofacScope.Resolve <FeaturesService>(); DisableFeatures(); comboObject.Active = 0; }
public EmployeeMovementsViewModel(EmployeeViewModel employeeViewModel, OpenStockDocumentsModel openStockDocumentsModel, EmployeeIssueRepository employeeIssueRepository, FeaturesService featuresService, ITdiCompatibilityNavigation navigation) { this.employeeViewModel = employeeViewModel ?? throw new ArgumentNullException(nameof(employeeViewModel)); this.openStockDocumentsModel = openStockDocumentsModel ?? throw new ArgumentNullException(nameof(openStockDocumentsModel)); this.employeeIssueRepository = employeeIssueRepository ?? throw new ArgumentNullException(nameof(employeeIssueRepository)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); this.navigation = navigation ?? throw new ArgumentNullException(nameof(navigation)); this.employeeIssueRepository.RepoUow = UoW; }
public IssueByIdentifierViewModel( IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IGuiDispatcher guiDispatcher, IUserService userService, ILifetimeScope autofacScope, StockRepository stockRepository, EmployeeRepository employeeRepository, FeaturesService featuresService, IValidator validator, BaseParameters baseParameters, IInteractiveQuestion interactive, IChangeableConfiguration configuration, SizeService sizeService, ICardReaderService cardReaderService = null) : base(navigation) { this.unitOfWorkFactory = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory)); this.guiDispatcher = guiDispatcher ?? throw new ArgumentNullException(nameof(guiDispatcher)); this.userService = userService ?? throw new ArgumentNullException(nameof(userService)); this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository)); this.validator = validator ?? throw new ArgumentNullException(nameof(validator)); this.BaseParameters = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters)); this.interactive = interactive ?? throw new ArgumentNullException(nameof(interactive)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); SizeService = sizeService ?? throw new ArgumentNullException(nameof(sizeService)); this.cardReaderService = cardReaderService; IsModal = false; EnableMinimizeMaximize = true; Title = "Выдача по картам СКУД"; UowOfDialog = unitOfWorkFactory.CreateWithoutRoot(); var entryBuilder = new CommonEEVMBuilderFactory <IssueByIdentifierViewModel>(this, this, UowOfDialog, navigation, autofacScope); if (cardReaderService != null) { cardReaderService.RefreshDevices(); cardReaderService.СardStatusRead += RusGuardService_СardStatusRead; cardReaderService.CardFamilies.ListChanged += CardFamilies_ListChanged; } UpdateState(); WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse).MakeByType().Finish(); Warehouse = stockRepository.GetDefaultWarehouse(UowOfDialog, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); //Настройка таймера сброса timerCleanSuccessfullyText = new Timer(40000); timerCleanSuccessfullyText.AutoReset = false; timerCleanSuccessfullyText.Elapsed += delegate(object sender, ElapsedEventArgs e) { guiDispatcher.RunInGuiTread(() => SuccessfullyText = null); }; ReadConfig(); }
public async Task GetAllShouldReturnZeroFeatures() { // Arrange var featuresService = new FeaturesService(_db, new Settings()); // Act var features = await featuresService.GetAll(); // Assert features.ShouldBeEmpty(); }
public ItemTypeViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, FeaturesService featuresService, SizeService sizeService, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); SizeService = sizeService; }
public async Task SetValueShouldFailIfMismatchTypeForDecimalValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("TaxPercent", "123").ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature TaxPercent is a decimal feature..."); }
public async Task SetValueShouldFailIfMismatchTypeForIntValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("Delay", false).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature Delay is an integer feature..."); }
public async Task SetValueShouldFailIfMismatchTypeForBooleanValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("Beta", 10).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature Beta is a boolean feature..."); }
public async Task GetValueShouldReturnStringValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act string value = await featuresService.GetValue <string>("Theme"); // Assert value.ShouldBe("light"); }
public async Task GetValueShouldReturnDecimalValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act decimal value = await featuresService.GetValue <decimal>("TaxPercent"); // Assert value.ShouldBe(12.5m); }
public async Task GetValueShouldReturnIntValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act int value = await featuresService.GetValue <int>("Delay"); // Assert value.ShouldBe(1000); }
public async Task GetShouldReturnNullIfNoFeatureFound() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var feature = await featuresService.Get("X"); // Assert feature.ShouldBeNull(); }
public CompletionViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IUserService userService, StockRepository stockRepository, FeaturesService featuresService, ILifetimeScope autofacScope, BaseParameters baseParameters, IInteractiveQuestion interactive, SizeService sizeService, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { var entryBuilder = new CommonEEVMBuilderFactory <Completion>(this, Entity, UoW, navigation, autofacScope); this.interactive = interactive; this.featuresService = featuresService; SizeService = sizeService; if (UoW.IsNew) { Entity.CreatedbyUser = userService.GetCurrentUser(UoW); } if (Entity.SourceWarehouse == null) { Entity.SourceWarehouse = stockRepository.GetDefaultWarehouse (UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); } WarehouseExpenseEntryViewModel = entryBuilder.ForProperty(x => x.SourceWarehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); if (Entity.ResultWarehouse == null) { Entity.ResultWarehouse = stockRepository.GetDefaultWarehouse (UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); } WarehouseReceiptEntryViewModel = entryBuilder.ForProperty(x => x.ResultWarehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); Validations.Clear(); Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters }, { nameof(IUnitOfWork), UoW } }))); Entity.PropertyChanged += Entity_PropertyChanged; lastWarehouse = Entity.SourceWarehouse; }
public async Task SetValueShouldFailIfMismatchTypeForStringValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("Theme", true).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature Theme is a string feature..."); }
public async Task GetAllShouldReturnFiveFeatures() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var features = await featuresService.GetAll(); // Assert features.Count.ShouldBe(5); }
public async Task GetShouldReturnAnExistingFeature() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var feature = await featuresService.Get("Beta"); // Assert feature.ShouldNotBeNull(); }
public async Task GetValueShouldReturnBooleanValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act bool value = await featuresService.GetValue <bool>("Beta"); // Assert value.ShouldBeTrue(); }
public HttpResponseMessage Add(FeatureCreateRequest model) // "public method named "Add" that returns an HtttpResponseMessage, that takes one parameter named "model" of type FeatureAddRequest" { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } //instantiate a a 'feature' entity service object FeaturesService feature = new FeaturesService(); ItemResponse <int> response = new ItemResponse <int>(); response.Item = feature.Create(model); //uses featuresService return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage Updates(FeatureUpdateRequest model) //binding to update request model. { // check data validation if (!ModelState.IsValid) //ModelState == collection of errors, is NOT valid... { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); //...return a error response. } //invoke the service method and return a SuccessResponse model, no item response is being returned like the above Create() method. FeaturesService feature = new FeaturesService(); // invoke the entity's service method feature.Update(model); // feature to return a model. return(Request.CreateResponse(HttpStatusCode.OK, true)); }
public async Task SetValueShouldFailIfNoFeatureFound() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); string featureName = "X"; // Act var exception = await featuresService.SetValue(featureName, "test").ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe($"The feature {featureName} does not exist..."); }
public async Task SetValueShouldFailIfNotInsideTheAvailableStringChoices() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); string featureName = "Theme"; string newValue = "Blue"; // Act var exception = await featuresService.SetValue(featureName, newValue).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe($"The value {newValue} is not a valid choice for feature {featureName}..."); }
// GET: Home public ActionResult Index() { UserContact dynamics = new UserContact(); FeaturesService _featuresService = new FeaturesService(); WorksService _worksService = new WorksService(); BannerService _bannerService = new BannerService(); dynamics.Features = _featuresService.GetFeatures().ToList(); dynamics.Works = _worksService.GetWorks().ToList(); dynamics.Banner = _bannerService.BannerGet(5); TempData["BannerTitle"] = dynamics.Banner.Title; TempData["BannerD"] = dynamics.Banner.Description; return(View(dynamics)); }