Esempio n. 1
0
        public void RightVersionNotFound()
        {
            // Arrange
            var unitOfWork     = unitOfWorkMockSetup.Object;
            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            UserIdentificationMock.Setup(s => s.UserName).Returns("user");

            VersioningManagerMock.Setup(s => s.GetVersionId <ServiceVersioned>(unitOfWork, _serviceId, null, false))
            .Returns((Guid?)null);

            var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);

            var service = new ServiceService(contextManager, translationManagerMockSetup.Object, TranslationManagerVModel, Logger, serviceUtilities,
                                             DataUtils, CommonService, new VmOwnerReferenceLogic(), CacheManager.TypesCache, LanguageCache, PublishingStatusCache,
                                             VersioningManager, gdService, UserOrganizationChecker);

            // Act
            var result = service.SaveService(new VmOpenApiServiceInVersionBase {
                Id = _serviceId
            }, false, DefaultVersion, false);

            // Assert
            result.Should().BeNull();
            translationManagerVModelMockSetup.Verify(x => x.Translate <IVmOpenApiServiceInVersionBase, ServiceVersioned>(It.IsAny <VmOpenApiServiceInVersionBase>(), unitOfWork), Times.Never());
        }
Esempio n. 2
0
        private void Initialize()
        {
            var environmentFactory = EnvironmentFactoryFactory.Create();

            _authenticationContext = Substitute.For <IAuthenticationContext>();

            var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations;

            _companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations;
            var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations);
            var userService     = new UserService(userOperations, _authenticationContext, settingProvider, null);

            _userId = userService.Register(new RegisterDto()
            {
                Name = "user", Email = EmailHelper.Generate(), Password = "******"
            }, null);

            _companyService = new CompanyService(_companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider));

            _authenticationContext.GetContextUser().Returns(_userId);

            _companyId = _companyService.Create("new company");

            _serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations;
            _serviceService    = new ServiceService(_serviceOperations, _companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider));
            _serviceId         = _serviceService.Create(new ServiceDto()
            {
                CompanyId = _companyId, Name = "new service"
            });

            _networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations;
            _networkService    = new NetworkService(_networkOperations, _serviceOperations, _companyOperations, _authenticationContext, null);
        }
Esempio n. 3
0
 public UserController(IOTContext context, IMapper mapper, IConfiguration config)
 {
     _service        = new UserService(context);
     _config         = config;
     _mapper         = mapper;
     _serviceService = new ServiceService(context);
 }
Esempio n. 4
0
        public async Task GetServiceNamesByTypeAsyncShouldWorkCorrectlyWhitTypeFix()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var serviceRepo = new EfDeletableEntityRepository <Service>(dbContext);

            var service = new ServiceService(serviceRepo);

            await serviceRepo.AddAsync(new Service
            {
                ServiceType = ServiceType.Mobile,
                Name        = "ASD",
            });

            await serviceRepo.AddAsync(new Service
            {
                ServiceType = ServiceType.Fix,
                Name        = "ASDD",
            });

            await serviceRepo.SaveChangesAsync();

            var services = await service.GetServiceNamesByTypeAsync <ServiceModel>("fix");

            Assert.Single(services);
            Assert.Collection(
                services,
                x => Assert.Equal("ASDD", x.Name));
        }
Esempio n. 5
0
        public void TryCreateServiceUnderOthersCompanyTest()
        {
            var environmentFactory    = EnvironmentFactoryFactory.Create();
            var authenticationContext = Substitute.For <IAuthenticationContext>();

            var userOperations    = environmentFactory.ManagementEnvironment.MgmtUserOperations;
            var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations;
            var settingProvider   = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations);

            var userService = new UserService(userOperations, authenticationContext, settingProvider, null);
            var userId1     = userService.Register(new RegisterDto()
            {
                Name = "user", Email = EmailHelper.Generate(), Password = "******"
            }, null);
            var userId2 = userService.Register(new RegisterDto()
            {
                Name = "user", Email = EmailHelper.Generate(), Password = "******"
            }, null);

            var companyService = new CompanyService(companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider));

            authenticationContext.GetContextUser().Returns(userId1);

            var companyId1 = companyService.Create("new company1");

            authenticationContext.GetContextUser().Returns(userId2);

            var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations;
            var serviceService    = new ServiceService(serviceOperations, companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider));

            serviceService.Create(new ServiceDto()
            {
                CompanyId = companyId1, Name = "svc"
            });
        }
Esempio n. 6
0
        public async Task GetAllTypesAsyncShouldWorkCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var serviceRepo = new EfDeletableEntityRepository <Service>(dbContext);

            var service = new ServiceService(serviceRepo);

            await serviceRepo.AddAsync(new Service
            {
                ServiceType = ServiceType.Mobile,
                Name        = "ASD",
            });

            await serviceRepo.AddAsync(new Service
            {
                ServiceType = ServiceType.Fix,
                Name        = "ASDD",
            });

            await serviceRepo.SaveChangesAsync();

            var types = await service.GetAllTypesAsync();

            Assert.Equal(2, types.Count());
            Assert.Contains("Mobile", types);
            Assert.Contains("Fix", types);
        }
Esempio n. 7
0
        public async Task GetByIdAsyncShouldWorkCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var serviceRepo = new EfDeletableEntityRepository <Service>(dbContext);

            var service = new ServiceService(serviceRepo);

            await serviceRepo.AddAsync(new Service
            {
                ServiceType = ServiceType.Mobile,
                Name        = "ASD",
            });

            await serviceRepo.AddAsync(new Service
            {
                ServiceType = ServiceType.Fix,
                Name        = "ASDD",
            });

            await serviceRepo.SaveChangesAsync();

            var serviceFromDB = await service.GetByIdAsync <ServiceModel>(1);

            Assert.Equal("ASD", serviceFromDB.Name);
            Assert.Equal(1, serviceFromDB.ServiceType);
        }
Esempio n. 8
0
        // GET: Organisation
        public ActionResult Index(Guid id)
        {
            var serviceService = new ServiceService();
            var model          = serviceService.GetService(id);

            return(View(model.data));
        }
Esempio n. 9
0
        protected async Task PlusRegionButtonHandler()
        {
            if (_serviceTypes == null)
            {
                _serviceTypes = await ServiceService.GetAsync(x =>
                                                              x.IsActive, x => x.OrderBy(y => y.ServiceTypeId), "ServiceType");
            }
            var region = new RegionReport();

            ReportVM.ProviderReport.Data.Add(region);

            foreach (var service in _serviceTypes)
            {
                region.Data.Add(new HeadAndValue
                {
                    ServiceTypeId   = service.ServiceTypeId,
                    ServiceTypeName = service.ServiceType.Name,
                    ServiceTypeDate = service.ServiceTypeDate,
                    OutOfContract   = true
                });
            }
            region.IsVisible     = true;
            region.OutOfContract = true;
            ReportVMEditContext  = new EditContext(ReportVM);
            await InvokeAsync(StateHasChanged);
        }
        public void AddServiceTest()
        {
            var serv = new ServiceService(new MVCHContext());

            serv.AddService(new Service
            {
                Name = "X-Ray"
            });
            serv.AddService(new Service
            {
                Name = "CT Scan"
            });
            serv.AddService(new Service
            {
                Name = "Dialysis"
            });
            serv.AddService(new Service
            {
                Name = "Complete Blood Count"
            });
            serv.AddService(new Service
            {
                Name = "Urinalysis"
            });
            serv.AddService(new Service
            {
                Name = "Fecalysis"
            });
            serv.AddService(new Service
            {
                Name = "Euthanasia"
            });
        }
Esempio n. 11
0
        private ServiceService CreateServiceService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new ServiceService(userId);

            return(service);
        }
Esempio n. 12
0
        public void Add_ExternalSourceExists()
        {
            // Arrange
            var sourceId       = "sourceId";
            var userName       = "******";
            var unitOfWork     = unitOfWorkMockSetup.Object;
            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            UserIdentificationMock.Setup(s => s.UserName).Returns(userName);
            ExternalSourceRepoMock.Setup(s => s.All())
            .Returns(new List <ExternalSource>()
            {
                new ExternalSource {
                    SourceId = sourceId, RelationId = userName, ObjectType = typeof(Model.Models.Service).Name
                }
            }.AsQueryable());
            var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);

            var service = new ServiceService(contextManager, translationManagerMockSetup.Object, TranslationManagerVModel, Logger, serviceUtilities,
                                             DataUtils, CommonService, new VmOwnerReferenceLogic(), CacheManager.TypesCache, LanguageCache, PublishingStatusCache,
                                             VersioningManager, gdService, UserOrganizationChecker);

            // Act
            Action act = () => service.AddService(new VmOpenApiServiceInVersionBase()
            {
                SourceId = sourceId
            }, false, DefaultVersion, false);

            // Assert
            act.ShouldThrowExactly <ExternalSourceExistsException>(string.Format(CoreMessages.OpenApi.ExternalSourceExists, sourceId));
        }
Esempio n. 13
0
 public DataController(IOTContext context, IMapper mapper)
 {
     _service                  = new ServiceLogService(new ServiceLogStorage(context));
     _servicesService          = new ServiceService(context);
     _servicePropertiesService = new ServicePropertiesService(context);
     _mapper = mapper;
 }
Esempio n. 14
0
        private void Initialize(string url)
        {
            _serializerSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Converters        = new JsonConverter[]
                {
                    new Newtonsoft.Json.Converters.JavaScriptDateTimeConverter(),
                    new MaintenanceJsonConverter()
                }
            };

            Check.IsNotNullOrWhiteSpace(url, "ZabbixApi.url");

            _url        = url;
            _webClient  = new WebClient();
            _httpClient = new HttpClient();

            Actions            = new ActionService(this);
            Alerts             = new AlertService(this);
            ApiInfo            = new ApiInfoService(this);
            Applications       = new ApplicationService(this);
            Correlations       = new CorrelationService(this);
            DiscoveredHosts    = new DiscoveredHostService(this);
            DiscoveredServices = new DiscoveredServiceService(this);
            DiscoveryChecks    = new DiscoveryCheckService(this);
            DiscoveryRules     = new DiscoveryRuleService(this);
            Events             = new EventService(this);
            GraphItems         = new GraphItemService(this);
            GraphPrototypes    = new GraphPrototypeService(this);
            Graphs             = new GraphService(this);
            History            = new HistoryService(this);
            HostGroups         = new HostGroupService(this);
            HostInterfaces     = new HostInterfaceService(this);
            HostPrototypes     = new HostPrototypeService(this);
            Hosts               = new HostService(this);
            IconMaps            = new IconMapService(this);
            ServiceService      = new ServiceService(this);
            Images              = new ImageService(this);
            ItemPrototypes      = new ItemPrototypeService(this);
            Items               = new ItemService(this);
            LLDRules            = new LLDRuleService(this);
            Maintenance         = new MaintenanceService(this);
            Maps                = new MapService(this);
            MediaTypes          = new MediaTypeService(this);
            Proxies             = new ProxyService(this);
            ScreenItems         = new ScreenItemService(this);
            Screens             = new ScreenService(this);
            Scripts             = new ScriptService(this);
            TemplateScreenItems = new TemplateScreenItemService(this);
            TemplateScreens     = new TemplateScreenService(this);
            Templates           = new TemplateService(this);
            TriggerPrototypes   = new TriggerPrototypeService(this);
            Triggers            = new TriggerService(this);
            UserGroups          = new UserGroupService(this);
            GlobalMacros        = new GlobalMacroService(this);
            HostMacros          = new HostMacroService(this);
            Users               = new UserService(this);
            ValueMaps           = new ValueMapService(this);
        }
Esempio n. 15
0
        protected void Initialize()
        {
            var environmentFactory = EnvironmentFactoryFactory.Create();

            _authenticationContext = Substitute.For <IAuthenticationContext>();
            var messagingServiceClient = Substitute.For <IMessagingServiceClient>();

            var userOperations    = environmentFactory.ManagementEnvironment.MgmtUserOperations;
            var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations;
            var settingProvider   = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations);

            var userService = new UserService(userOperations, _authenticationContext, settingProvider, null);

            _userId = userService.Register(new RegisterDto()
            {
                Name = "user", Email = EmailHelper.Generate(), Password = "******"
            }, null);

            _companyService = new CompanyService(companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider));

            _authenticationContext.GetContextUser().Returns(_userId);

            _companyId = _companyService.Create("new company");

            var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations;

            _serviceService = new ServiceService(serviceOperations, companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider));
            _serviceId      = _serviceService.Create(new ServiceDto()
            {
                CompanyId = _companyId, Name = "new service"
            });

            var networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations;
            var telemetryDataSinkSetupServiceClient = Substitute.For <ITelemetryDataSinkSetupServiceClient>();

            telemetryDataSinkSetupServiceClient.GetTelemetryDataSinksMetadata().Returns(
                new TelemetryDataSinksMetadataDtoClient
            {
                Incoming = new List <TelemetryDataSinkMetadataDtoClient>
                {
                    new TelemetryDataSinkMetadataDtoClient
                    {
                        Name              = "test",
                        Description       = null,
                        ParametersToInput = new List <string> {
                            "k1", "k2"
                        }
                    }
                }
            });
            _networkService = new NetworkService(networkOperations, serviceOperations, companyOperations, _authenticationContext, telemetryDataSinkSetupServiceClient);

            messagingServiceClient.Initialize("1234").ReturnsForAnyArgs(1);

            var deviceOperations = environmentFactory.ManagementEnvironment.MgmtDeviceOperations;

            _deviceService = new DeviceService(deviceOperations, networkOperations, serviceOperations, companyOperations,
                                               _authenticationContext, messagingServiceClient);
        }
Esempio n. 16
0
        public void TryCreateDeviceUnderOtherNetworkTest()
        {
            var environmentFactory    = EnvironmentFactoryFactory.Create();
            var authenticationContext = Substitute.For <IAuthenticationContext>();
            var messagingService      = Substitute.For <IMessagingServiceClient>();

            var userOperations    = environmentFactory.ManagementEnvironment.MgmtUserOperations;
            var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations;
            var settingProvider   = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations);

            var userService = new UserService(userOperations, authenticationContext, settingProvider, null);
            var userId1     =
                userService.Register(new RegisterDto()
            {
                Name = "user", Email = EmailHelper.Generate(), Password = "******"
            }, null);

            var companyService = new CompanyService(companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider));

            authenticationContext.GetContextUser().Returns(userId1);

            var companyId1 = companyService.Create("new company1");

            var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations;
            var serviceService    = new ServiceService(serviceOperations, companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider));

            var serviceId1 = serviceService.Create(new ServiceDto()
            {
                CompanyId = companyId1, Name = "svc"
            });

            var companyId2 = companyService.Create("new company2");

            var serviceId2 = serviceService.Create(new ServiceDto()
            {
                CompanyId = companyId2, Name = "svc"
            });

            var networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations;
            var networkService    = new NetworkService(networkOperations, serviceOperations, companyOperations, authenticationContext, null);

            var deviceOperations = environmentFactory.ManagementEnvironment.MgmtDeviceOperations;
            var deviceService    = new DeviceService(deviceOperations, networkOperations, serviceOperations, companyOperations, authenticationContext, messagingService);

            var networkId2 = networkService.Create(new NetworkDto()
            {
                ServiceId = serviceId2, CompanyId = companyId2, Name = "svc"
            });

            var device = new DeviceDto()
            {
                NetworkId = networkId2,
                CompanyId = companyId1,
                ServiceId = serviceId1,
                Name      = "test"
            };

            deviceService.Create(device);
        }
 public MostWantedServicesReport()
 {
     InitializeComponent();
     _service        = new ServiceProvisionService();
     _userService    = new UserService();
     _clientService  = new ClientService();
     _serviceService = new ServiceService();
 }
Esempio n. 18
0
 public SchedulePage()
 {
     InitializeComponent();
     _service        = new ServiceProvisionService();
     _userService    = new UserService();
     _clientService  = new ClientService();
     _serviceService = new ServiceService();
 }
Esempio n. 19
0
        public async Task <Service> GetServiceForCustomer([FromUri] ServiceForCustomer req)
        {
            ServiceService.DisableProxy();

            var service = await ServiceService.GetServiceForCustomerAsync(req.CustomerId, req.ServiceId);

            return(service);
        }
Esempio n. 20
0
        protected async Task HandleSubmit()
        {
            PeriodVMEditContext = new EditContext(AdminPeriodVM);

            if (PeriodVMEditContext.Validate())
            {
                var period = (await PeriodService.GetAsync(x => x.Year == AdminPeriodVM.PeriodeStartDate.Year)).FirstOrDefault();

                if (period != null)
                {
                    period.Description      = AdminPeriodVM.Description.Trim();
                    period.PeriodeStartDate = AdminPeriodVM.PeriodeStartDate;
                    period.PeriodeEndDate   = AdminPeriodVM.PeriodeEndDate;
                    period.PeriodValue      = (decimal)AdminPeriodVM.PeriodValue;
                    PeriodService.Update(period);
                }
                else
                {
                    period = new Period
                    {
                        Year             = AdminPeriodVM.PeriodeStartDate.Year,
                        Description      = AdminPeriodVM.Description.Trim(),
                        PeriodeStartDate = AdminPeriodVM.PeriodeStartDate,
                        PeriodeEndDate   = AdminPeriodVM.PeriodeEndDate,
                        PeriodValue      = (decimal)AdminPeriodVM.PeriodValue,
                        BudgetFrames     = new List <BudgetFrame>()
                    };

                    var regions = await RegionService.GetAsync();

                    var services = await ServiceService.GetAsync(x =>
                                                                 x.ServiceTypeDate <= AdminPeriodVM.PeriodeStartDate &&
                                                                 x.IsActive);

                    foreach (var region in regions)
                    {
                        foreach (var service in services)
                        {
                            period.BudgetFrames.Add(
                                new BudgetFrame
                            {
                                RegionId = region.Id,
                                Year     = AdminPeriodVM.PeriodeStartDate.Year,
                                Service  = service,
                                Head     = 0,
                                Value    = 0
                            });
                        }
                    }
                    await PeriodService.AddAsync(period);
                }
                await PeriodService.SaveChangesAsync(AppUser.Instance.FullName);

                PeriodVMs = Mapper.Map <IEnumerable <PeriodVM> >(await PeriodService.GetAsync());
                ToggleView();
            }
            StateHasChanged();
        }
Esempio n. 21
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            // calculate something for us to return
            int length = (activity.Text ?? string.Empty).Length;

            // direct to corresponding the interface
            if (activity.Text.ToUpper() == "SALES")
            {
                ISalesService obj = new SalesService();
                await obj.Service(context, result);
            }
            else if (activity.Text.ToUpper() == "SERVICE")
            {
                IServiceService obj = new ServiceService();
                await obj.Service(context, result);
            }
            else if (activity.Text.ToUpper() == "PARTS")
            {
                IPartsService obj = new PartsService();
                await obj.Service(context, result);
            }
            else if (activity.Text.ToUpper() == "MENU")
            {
                // Main menu
                Activity reply = activity.CreateReply($"Please choose one of the departments you want to reach:");

                reply.Type       = ActivityTypes.Message;
                reply.TextFormat = TextFormatTypes.Plain;

                reply.SuggestedActions = new SuggestedActions()
                {
                    Actions = new List <CardAction>()
                    {
                        new CardAction()
                        {
                            Title = "Sales", Type = ActionTypes.ImBack, Value = "SALES"
                        },
                        new CardAction()
                        {
                            Title = "Service", Type = ActionTypes.ImBack, Value = "SERVICE"
                        },
                        new CardAction()
                        {
                            Title = "Parts", Type = ActionTypes.ImBack, Value = "PARTS"
                        }
                    }
                };
                await context.PostAsync(reply);
            }
            else
            {
                await context.PostAsync($"You have entered an invalid option.  Please try again or type \"Menu\" to display the menu:");
            }
            context.Wait(MessageReceivedAsync);
        }
Esempio n. 22
0
        public async Task <Service> Put(Service service)
        {
            if (ModelState.IsValid)
            {
                await ServiceService.UpdateAsync(service);
            }

            return(service);
        }
Esempio n. 23
0
 public EditServiceWindow(Service service)
 {
     InitializeComponent();
     _serviceService  = new ServiceService();
     _isUpdateMode    = true;
     _service         = service;
     TbxName.Text     = service.Name;
     TbxDesc.Text     = service.Description;
     TbxDuration.Text = service.Duration.ToString();
     TbxPrice.Text    = service.Price.ToString();
 }
Esempio n. 24
0
        protected async Task HandleSubmit()
        {
            if (ServiceEditContext.Validate())
            {
                var service = (await ServiceService.GetAsync(
                                   x => x.ServiceTypeId == AdminServiceVM.SelectedService &&
                                   x.ServiceTypeDate.Equals(AdminServiceVM.Date), null, "ServiceType"))
                              .FirstOrDefault();
                if (service == null)
                {
                    service = new Data.Service
                    {
                        Price           = (decimal)AdminServiceVM.Price,
                        ServiceTypeDate = (DateTime)AdminServiceVM.Date,
                        IsActive        = true
                    };

                    if (AdminServiceVM.SelectedService > 0)
                    {
                        service.ServiceTypeId = AdminServiceVM.SelectedService;

                        var oldService = (await ServiceService.GetAsync(
                                              x => x.ServiceTypeId == AdminServiceVM.SelectedService &&
                                              x.IsActive,
                                              null, "ServiceType"))
                                         .FirstOrDefault();
                        if (oldService != null)
                        {
                            oldService.IsActive = false;
                            ServiceService.Update(oldService);
                        }
                    }
                    else
                    {
                        service.ServiceType = new Data.ServiceType
                        {
                            Name        = AdminServiceVM.ServiceName,
                            Description = AdminServiceVM.Description
                        };
                    }
                    await ServiceService.AddAsync(service);
                }
                else
                {
                    service.Price = (decimal)AdminServiceVM.Price;
                    ServiceService.Update(service);
                }
                await ServiceService.SaveChangesAsync(AppUser.Instance.FullName);
                await TableInitialiser();

                ToggleView();
            }
            await InvokeAsync(StateHasChanged);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            ServiceService serviceService = new ServiceService();
            String         newPrice       = textBox5.Text.ToString();
            double         price          = Convert.ToDouble(newPrice);

            serviceService.addNewService(textBox4.Text.ToString(), price);

            textBox4.Clear();
            textBox5.Clear();
        }
Esempio n. 26
0
 public TelaProcedimento()
 {
     InitializeComponent();
     ConfigurarCombobox();
     ConfigurarDatagrid();
     procedureService = new ProcedureService();
     productService   = new ProductService();
     animalService    = new AnimalService();
     serviceService   = new ServiceService();
     voluntaryService = new VoluntaryService();
 }
Esempio n. 27
0
        public void GdAttached_MapDataFormGD()
        {
            // Arrange
            var userName     = "******";
            var gdId         = Guid.NewGuid();
            var gdType       = ServiceTypeEnum.PermissionAndObligation.ToString();
            var gdChargeType = ServiceChargeTypeEnum.Free.ToString();
            var vm           = new VmOpenApiServiceInVersionBase
            {
                Id = _serviceId,
                StatutoryServiceGeneralDescriptionId = gdId.ToString()
            };
            var unitOfWork     = unitOfWorkMockSetup.Object;
            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            UserIdentificationMock.Setup(s => s.UserName).Returns(userName);

            VersioningManagerMock.Setup(s => s.GetVersionId <ServiceVersioned>(unitOfWork, _serviceId, null, false))
            .Returns(_serviceVersionedId);

            gdServiceMock.Setup(g => g.GetGeneralDescriptionSimple(unitOfWork, It.IsAny <Guid>()))
            .Returns(new VmOpenApiGeneralDescriptionVersionBase()
            {
                Type = gdType,
                ServiceChargeType = gdChargeType
            });
            gdServiceMock.Setup(g => g.GetGeneralDescriptionVersionBase(It.IsAny <Guid>(), 0, true))
            .Returns(new VmOpenApiGeneralDescriptionVersionBase()
            {
                Type = gdType,
                ServiceChargeType = gdChargeType
            });

            var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);

            var service = new ServiceService(contextManager, translationManagerMockSetup.Object, TranslationManagerVModel, Logger, serviceUtilities,
                                             DataUtils, CommonService, new VmOwnerReferenceLogic(), CacheManager.TypesCache, LanguageCache, PublishingStatusCache,
                                             VersioningManager, gdService, UserOrganizationChecker);

            // Act
            var result = service.SaveService(vm, false, DefaultVersion, true);

            // Assert
            result.Should().NotBeNull();
            var vmResult = Assert.IsType <V7VmOpenApiService>(result);

            vmResult.StatutoryServiceGeneralDescriptionId.Should().Be(gdId);
            vmResult.Type.Should().Be(gdType);
            vmResult.ServiceChargeType.Should().BeNull(); // service charge type is not gotten from GD (in GET) so should be null
            translationManagerVModelMockSetup.Verify(x => x.Translate <IVmOpenApiServiceInVersionBase, ServiceVersioned>(It.IsAny <VmOpenApiServiceInVersionBase>(), unitOfWork), Times.Once());
            translationManagerMockSetup.Verify(x => x.Translate <ServiceVersioned, VmOpenApiServiceVersionBase>(It.IsAny <ServiceVersioned>()), Times.Once());
        }
Esempio n. 28
0
        private void Initialize()
        {
            var environmentFactory = EnvironmentFactoryFactory.Create();

            _authenticationContext  = Substitute.For <IAuthenticationContext>();
            _messagingServiceClient = Substitute.For <IMessagingServiceClient>();

            var userOperations    = environmentFactory.ManagementEnvironment.MgmtUserOperations;
            var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations;
            var settingProvider   = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations);

            var userService = new UserService(userOperations, _authenticationContext, settingProvider, null);

            _userId = userService.Register(new RegisterDto()
            {
                Name = "user", Email = EmailHelper.Generate(), Password = "******"
            }, null);

            _companyService = new CompanyService(companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider));

            _authenticationContext.GetContextUser().Returns(_userId);

            _companyId = _companyService.Create("new company");

            var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations;

            _serviceService = new ServiceService(serviceOperations, companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider));
            _serviceId      = _serviceService.Create(new ServiceDto()
            {
                CompanyId = _companyId, Name = "new service"
            });

            var networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations;

            _networkService = new NetworkService(networkOperations, serviceOperations, companyOperations, _authenticationContext, null);

            var network = new NetworkDto()
            {
                Name            = "new network",
                ParentNetworkId = null,
                CompanyId       = _companyId,
                ServiceId       = _serviceId
            };

            _networkId = _networkService.Create(network);

            _messagingServiceClient.Initialize("1234").ReturnsForAnyArgs(1);

            var deviceOperations = environmentFactory.ManagementEnvironment.MgmtDeviceOperations;

            _deviceService = new DeviceService(deviceOperations, networkOperations, serviceOperations, companyOperations,
                                               _authenticationContext, _messagingServiceClient);
        }
Esempio n. 29
0
        protected async Task PlusRegionHandler(ChangeEventArgs args)
        {
            if (!string.IsNullOrEmpty((string)args.Value))
            {
                if (_serviceTypes == null)
                {
                    _serviceTypes = await ServiceService.GetAsync(x =>
                                                                  x.IsActive, x => x.OrderBy(y => y.ServiceTypeId), "ServiceType");
                }

                var regionId = Int32.Parse((string)args.Value);

                var region = ReportVM.ProviderReport.Data
                             .Where(x => x.RegionId == regionId)
                             .FirstOrDefault();

                if (region == null)
                {
                    region = new RegionReport
                    {
                        RegionId   = regionId,
                        RegionName = ReportVM.Regions
                                     .Where(x => x.ValueInt == regionId)
                                     .Select(x => x.Text)
                                     .FirstOrDefault(),
                        OutOfContract = true
                    };
                    ReportVM.ProviderReport.Data.Add(region);
                }

                var attachedServiceTypeIds = region?.Data.Select(x => x.ServiceTypeId).ToList();
                foreach (var service in _serviceTypes)
                {
                    if (attachedServiceTypeIds == null || !attachedServiceTypeIds.Contains(service.ServiceTypeId))
                    {
                        region.Data.Add(new HeadAndValue
                        {
                            ServiceTypeId   = service.ServiceTypeId,
                            ServiceTypeName = service.ServiceType.Name,
                            ServiceTypeDate = service.ServiceTypeDate,
                            OutOfContract   = true
                        });
                    }
                }
                region.IsVisible    = true;
                ReportVMEditContext = new EditContext(ReportVM);
            }

            await JSRuntime.InvokeVoidAsync("setZeroSelectElement", newregion);

            ReportVM.SelectedRegionId = 0;
            await InvokeAsync(StateHasChanged);
        }
Esempio n. 30
0
        public void GdAttached_AttachProposedChannels()
        {
            // Arrange
            var userName     = "******";
            var gdId         = Guid.NewGuid();
            var descriptions = TestDataFactory.CreateLocalizedList("Description");
            var entityName   = typeof(Model.Models.Service).Name;
            var vm           = new VmOpenApiServiceInVersionBase
            {
                Id = _serviceId,
                StatutoryServiceGeneralDescriptionId = gdId.ToString()
            };
            var unitOfWork     = unitOfWorkMockSetup.Object;
            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            UserIdentificationMock.Setup(s => s.UserName).Returns(userName);

            VersioningManagerMock.Setup(s => s.GetVersionId <ServiceVersioned>(unitOfWork, _serviceId, null, false))
            .Returns(_serviceVersionedId);

            gdServiceMock.Setup(g => g.GetGeneralDescriptionVersionBase(It.IsAny <Guid>(), 0, true))
            .Returns(new VmOpenApiGeneralDescriptionVersionBase()
            {
                ServiceChannels = new List <V6VmOpenApiServiceServiceChannel>
                {
                    new V6VmOpenApiServiceServiceChannel {
                        ServiceChannel = new VmOpenApiItem {
                            Id = _channelId
                        }, Description = descriptions
                    }
                }
            });

            var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);

            var service = new ServiceService(contextManager, translationManagerMockSetup.Object, TranslationManagerVModel, Logger, serviceUtilities,
                                             DataUtils, CommonService, new VmOwnerReferenceLogic(), CacheManager.TypesCache, LanguageCache, PublishingStatusCache,
                                             VersioningManager, gdService, UserOrganizationChecker);

            // Act
            var result = service.SaveService(vm, false, DefaultVersion, true);

            // Assert
            result.Should().NotBeNull();
            var vmResult = Assert.IsType <V7VmOpenApiService>(result);

            vmResult.StatutoryServiceGeneralDescriptionId.Should().Be(gdId);
            vmResult.ServiceChannels.Should().NotBeNull();
            vmResult.ServiceChannels.Count.Should().Be(1);
            translationManagerVModelMockSetup.Verify(x => x.Translate <IVmOpenApiServiceInVersionBase, ServiceVersioned>(It.IsAny <VmOpenApiServiceInVersionBase>(), unitOfWork), Times.Once());
            translationManagerMockSetup.Verify(x => x.Translate <ServiceVersioned, VmOpenApiServiceVersionBase>(It.IsAny <ServiceVersioned>()), Times.Once());
        }
Esempio n. 31
0
 // Use this for initialization
 void Start()
 {
     service = new ServiceService ();
 }