public async Task GetOrAddAatfDeliveryLocation_NoMatchingApprovalNumber_ReturnsNewAatfDeliveryLocation()
        {
            // Arrange
            var dbContextHelper = new DbContextHelper();
            var context = A.Fake<WeeeContext>();

            var aatfDeliveryLocationDb = new AatfDeliveryLocation("xxx", "BBB");
            var aatfDeliveryLocations = dbContextHelper.GetAsyncEnabledDbSet(new List<AatfDeliveryLocation> { aatfDeliveryLocationDb });
            A.CallTo(() => context.AatfDeliveryLocations)
                .Returns(aatfDeliveryLocations);

            var dataAccess = new DataReturnVersionBuilderDataAccess(A.Dummy<Scheme>(), A.Dummy<Quarter>(), context);

            // Act
            var result = await dataAccess.GetOrAddAatfDeliveryLocation("AAA", "BBB");

            // Assert
            Assert.NotNull(result);
            Assert.NotSame(aatfDeliveryLocationDb, result);
            Assert.Equal("AAA", result.ApprovalNumber);
            Assert.Equal("BBB", result.FacilityName);
            Assert.Contains(result, dataAccess.CachedAatfDeliveryLocations.Values);
            A.CallTo(() => aatfDeliveryLocations.Add(result))
                .MustHaveHappened();
        }
        public async Task HandleAsync_ReturnsRolesFromDatabase()
        {
            // Arrange
            var role1 = new Role("InternalAdmin", "Administrator");
            var role2 = new Role("InternalUser", "Internal User");
            var role3 = new Role("ExternalUser", "External User");

            var roles = new List<Role> { role1, role2, role3 };
            DbContextHelper dbHelper = new DbContextHelper();

            var weeeContext = A.Fake<WeeeContext>();
            A.CallTo(() => weeeContext.Roles)
                .Returns(dbHelper.GetAsyncEnabledDbSet(roles));

            var handler = new GetRolesHandler(A.Dummy<IWeeeAuthorization>(), weeeContext);

            // Act
            var result = await handler.HandleAsync(new GetRoles());

            // Assert
            Assert.Equal(3, result.Count);
            Assert.Collection(result,
                r1 => Assert.Equal("InternalAdmin", r1.Name),
                r2 => Assert.Equal("InternalUser", r2.Name),
                r3 => Assert.Equal("ExternalUser", r3.Name));
        }
        public GetLatestMemberUploadListHandlerTests()
        {
            weeeContext = A.Fake<WeeeContext>();
            weeeContextHelper = new DbContextHelper();
            mapper = A.Fake<IMap<IEnumerable<MemberUpload>, LatestMemberUploadList>>();

            memberUploadRowVersion = 0;
        }
        public GetUserDataHandlerTests()
        {
            context = A.Fake<WeeeContext>();
            weeeAuthorization = A.Fake<IWeeeAuthorization>();
            userContext = A.Fake<IUserContext>();

            userHelper = new UserHelper();
            helper = new DbContextHelper();
        }
        public FindMatchingOrganisationsDataAccessTests()
        {
            context = A.Fake<WeeeContext>();

            dbContextHelper = new DbContextHelper();

            // By default, all DbSets used by these tests return an empty list of data
            A.CallTo(() => context.Organisations)
                .Returns(dbContextHelper.GetAsyncEnabledDbSet(new List<Organisation>()));

            A.CallTo(() => context.OrganisationUsers)
                .Returns(dbContextHelper.GetAsyncEnabledDbSet(new List<OrganisationUser>()));
        }
        public JoinOrganisationDataAccessTests()
        {
            context = A.Fake<WeeeContext>();
            contextHelper = new DbContextHelper();

            // By default, context returns empty list for each dbset used in these tests
            A.CallTo(() => context.OrganisationUsers)
                .Returns(contextHelper.GetAsyncEnabledDbSet(new List<OrganisationUser>()));

            A.CallTo(() => context.Organisations)
                .Returns(contextHelper.GetAsyncEnabledDbSet(new List<Organisation>()));

            A.CallTo(() => context.Users)
                .Returns(contextHelper.GetAsyncEnabledDbSet(new List<User>()));
        }
        public async Task GetPreviousSubmission_ThrowsInvalidOperationException_IfSpecifiedDataReturnVersionIsNotSavedInDatabase()
        {
            var dbHelper = new DbContextHelper();

            var weeeContext = A.Fake<WeeeContext>();
            A.CallTo(() => weeeContext.DataReturnVersions)
                .Returns(dbHelper.GetAsyncEnabledDbSet(new List<DataReturnVersion>()));

            DataReturnSubmissionsDataAccess dataAccess = new DataReturnSubmissionsDataAccess(weeeContext);

            var dataReturnVersion = A.Fake<DataReturnVersion>();
            A.CallTo(() => dataReturnVersion.IsSubmitted)
                .Returns(true);

            await Assert.ThrowsAsync<InvalidOperationException>(() => dataAccess.GetPreviousSubmission(dataReturnVersion));
        }
Exemple #8
0
        public TpxinPushDataMap()
        {
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Id)
            .IsRequired();
            this.Property(t => t.Nodeid)
            .IsRequired();
            this.Property(t => t.Typeid)
            .IsRequired();
            this.Property(t => t.Title)
            .IsRequired()
            .HasMaxLength(50);
            this.Property(t => t.Content)
            .IsRequired()
            .HasMaxLength(250);
            this.Property(t => t.Url)
            .IsRequired()
            .HasMaxLength(100);
            this.Property(t => t.Expecttime)
            .IsRequired();
            this.Property(t => t.Pushtime)
            .IsRequired();
            this.Property(t => t.Status)
            .IsRequired();
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("TPXIN_PUSH_DATA", DbContextHelper.GetOwnerByTableName("TPXIN_PUSH_DATA"));
            this.Property(t => t.Id).HasColumnName("ID");
            this.Property(t => t.Nodeid).HasColumnName("NODEID");
            this.Property(t => t.Typeid).HasColumnName("TYPEID");
            this.Property(t => t.Title).HasColumnName("TITLE");
            this.Property(t => t.Content).HasColumnName("CONTENT");
            this.Property(t => t.Url).HasColumnName("URL");
            this.Property(t => t.Expecttime).HasColumnName("EXPECTTIME");
            this.Property(t => t.Pushtime).HasColumnName("PUSHTIME");
            this.Property(t => t.Status).HasColumnName("STATUS");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
        }
Exemple #9
0
        public Ttqm2InfoMap()
        {
            // Primary Key
            this.HasKey(t => t.Infoid);
            // Properties
            this.Property(t => t.Infoid)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Nodeid)
            .IsRequired();
            this.Property(t => t.Pwd)
            .IsRequired()
            .HasMaxLength(100);
            this.Property(t => t.Typeid)
            .IsRequired();
            this.Property(t => t.Price)
            .IsRequired()
            .HasPrecision(12, 2);
            this.Property(t => t.Fee)
            .IsRequired()
            .HasPrecision(12, 2);
            this.Property(t => t.Status)
            .IsRequired();
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(100);
            this.Property(t => t.Modifytime)
            .IsRequired();

            // Table & Column Mappings
            this.ToTable("TTQM2_INFO", DbContextHelper.GetOwnerByTableName("TTQM2_INFO"));
            this.Property(t => t.Infoid).HasColumnName("INFOID");
            this.Property(t => t.Nodeid).HasColumnName("NODEID");
            this.Property(t => t.Pwd).HasColumnName("PWD");
            this.Property(t => t.Typeid).HasColumnName("TYPEID");
            this.Property(t => t.Price).HasColumnName("PRICE");
            this.Property(t => t.Fee).HasColumnName("FEE");
            this.Property(t => t.Status).HasColumnName("STATUS");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
            this.Property(t => t.Modifytime).HasColumnName("MODIFYTIME");
        }
        public TcsChangeHisMap()
        {
            // Primary Key
            this.HasKey(t => t.Hisid);
            // Properties
            this.Property(t => t.Hisid)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Nodeid)
            .IsRequired();
            this.Property(t => t.Typeid)
            .IsRequired();
            this.Property(t => t.Olddata)
            .IsOptional()
            .HasMaxLength(4000);
            this.Property(t => t.Newdata)
            .IsOptional()
            .HasMaxLength(4000);
            this.Property(t => t.Fee)
            .IsRequired();
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Opnodeid)
            .IsOptional();
            this.Property(t => t.Note)
            .IsOptional()
            .HasMaxLength(400);
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(400);

            // Table & Column Mappings
            this.ToTable("TCS_CHANGE_HIS", DbContextHelper.GetOwnerByTableName("TCS_CHANGE_HIS"));
            this.Property(t => t.Hisid).HasColumnName("HISID");
            this.Property(t => t.Nodeid).HasColumnName("NODEID");
            this.Property(t => t.Typeid).HasColumnName("TYPEID");
            this.Property(t => t.Olddata).HasColumnName("OLDDATA");
            this.Property(t => t.Newdata).HasColumnName("NEWDATA");
            this.Property(t => t.Fee).HasColumnName("FEE");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Opnodeid).HasColumnName("OPNODEID");
            this.Property(t => t.Note).HasColumnName("NOTE");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
        }
        public async void ShouldDeleteExam()
        {
            var client          = httpClientFactory.CreateClient();
            var httpCallHelper  = new HttpCallHelper(client);
            var dbContextHelper = new DbContextHelper(this.dbContextFactory);
            var tuple           = await httpCallHelper.CreateExam();

            var loggedUser1 = tuple.Item1;
            var examDto1    = tuple.Item3;

            tuple = await httpCallHelper.CreateExam();

            var loggedUser2   = tuple.Item1;
            var examDto2      = tuple.Item3;
            var link1         = $"exams/{examDto1.Id}";
            var link2         = $"exams/{examDto2.Id}";
            var linkNotExists = $"exams/{int.MaxValue}";

            var exam1 = await dbContextHelper.FindExamAsync(examDto1.Id);

            var exam2 = await dbContextHelper.FindExamAsync(examDto2.Id);

            AssertHelper.AssertExamNotDeleted(exam1);
            AssertHelper.AssertExamNotDeleted(exam2);

            //unauthorized
            await client.DeleteUnauthorized(link1);

            //not this users exam
            client.Authorize(loggedUser1.Token);
            await client.DeleteNotFound(link2);

            //not existing
            await client.DeleteNotFound(linkNotExists);

            //success
            var responseExam = await client.DeleteExamSucessfully(link1);

            Assert.Equal(responseExam.Id, examDto1.Id);
            exam1 = dbContextHelper.SelectExamFirstOrDefault(examDto1.Id);
            Assert.Null(exam1);

            exam1 = dbContextHelper.SelectExamIgnoreQueryFiltersTakeFirst(examDto1.Id);
            AssertHelper.AssertExamDeleted(exam1);
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        public TpxinPaiHisOldMap()
        {
            // Primary Key
            this.HasKey(t => t.Hisid);
            // Properties
            this.Property(t => t.Hisid)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Nodeid)
            .IsRequired();
            this.Property(t => t.Num)
            .IsRequired();
            this.Property(t => t.Price)
            .IsRequired()
            .HasPrecision(12, 2);
            this.Property(t => t.Totalprice)
            .IsRequired()
            .HasPrecision(12, 2);
            this.Property(t => t.Status)
            .IsRequired();
            this.Property(t => t.Rankinfo)
            .IsOptional()
            .HasMaxLength(100);
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(100);
            this.Property(t => t.Configid)
            .IsRequired();

            // Table & Column Mappings
            this.ToTable("TPXIN_PAI_HIS_OLD", DbContextHelper.GetOwnerByTableName("TPXIN_PAI_HIS_OLD"));
            this.Property(t => t.Hisid).HasColumnName("HISID");
            this.Property(t => t.Nodeid).HasColumnName("NODEID");
            this.Property(t => t.Num).HasColumnName("NUM");
            this.Property(t => t.Price).HasColumnName("PRICE");
            this.Property(t => t.Totalprice).HasColumnName("TOTALPRICE");
            this.Property(t => t.Status).HasColumnName("STATUS");
            this.Property(t => t.Rankinfo).HasColumnName("RANKINFO");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
            this.Property(t => t.Configid).HasColumnName("CONFIGID");
        }
Exemple #13
0
        /// <summary>
        ///Delete two foreign key refernces from the mapping table
        /// </summary>
        public virtual void DeleteManyToMany <T>(IDwarf obj1, IDwarf obj2, string alternateTableName = null)
        {
            var type1 = obj1.GetType();
            var type2 = obj2.GetType();

            var tableName = ManyToManyAttribute.GetManyToManyTableName(type1, type2, alternateTableName);

            DbContextHelper <T> .ClearCacheForType(type1);

            DbContextHelper <T> .ClearCacheForType(type2);

            var query = new QueryBuilder()
                        .DeleteFrom("dbo.[" + tableName + "]")
                        .Where("[" + type1.Name + "Id] = " + ValueToSqlString(obj1.Id))
                        .Where("[" + type2.Name + "Id] = " + ValueToSqlString(obj2.Id));

            ExecuteNonQuery <T>(query);
        }
Exemple #14
0
        public async Task GetServiceListWithName(string nameOfService)
        {
            // Arrange
            using (var context = DbContextHelper.GetInMemoryDbContext())
            {
                var service         = new ServiceService(context);
                var searchParameter = new ServiceSearchParameter
                {
                    Name = nameOfService
                };

                // Act
                var events = await service.GetServicesAsync(searchParameter);

                // Assert
                Assert.True(!events.Any(x => !x.Name.Contains(nameOfService)));
            }
        }
        public async Task Start(string connectionString, string rabbitMqUser, string rabbitMqPassword, string rabbitMqHost)
        {
            _connectionString = connectionString;

            Core core = await _coreHelper.GetCore();

            DbContextHelper dbContextHelper = new DbContextHelper(connectionString);

            _container.Register(Component.For <Core>().Instance(core));
            _container.Register(Component.For <DbContextHelper>().Instance(dbContextHelper));
            _container.Register(Component.For <IWorkOrdersLocalizationService>().Instance(_workOrdersLocalizationService));
            _container.Install(
                new RebusHandlerInstaller(),
                new RebusInstaller(connectionString, 1, 1, rabbitMqUser, rabbitMqPassword, rabbitMqHost)
                );

            _bus = _container.Resolve <IBus>();
        }
Exemple #16
0
        private List <CalendarModel> GetPrivateRoomCourseEventCalendar(string roomName)
        {
            var privateRoom = GetPrivateRoom(roomName);
            var fullCourse  = DbContextHelper.GetCourseInfo(privateRoom.Courses);
            List <CalendarModel> listCalendarEvent = new List <CalendarModel>();

            foreach (var course in fullCourse)
            {
                var courseTitle = $"{course.CourseAcronym} ({course.GroupNumber})";
                var courseEvent = new CalendarModel(course.CourseInfo, courseTitle, course.CourseName);
                courseEvent.EventId = course.CourseId;
                var labEvent = new CalendarModel(course.CourseInfo1, courseTitle, course.CourseName);
                labEvent.EventId = course.CourseId;
                listCalendarEvent.Add(courseEvent);
                listCalendarEvent.Add(labEvent);
            }
            return(listCalendarEvent);
        }
    public async Task CreateWorkflowCommand_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        CreateWorkflowCommand request = new()
        {
            Workflow = MockViewModelHelper.GetNewWorkflow()
        };

        // Act
        WorkflowHandler handler  = new(unitOfWork, mapper);
        OperationResult response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
    }
Exemple #18
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            College collegeEdit = collegeGrd.SelectedItem as College;

            if (collegeEdit == null)
            {
                return;
            }
            CollegeDialog collegeDialog = new CollegeDialog(new College(collegeEdit))
            {
                Title = "Editar Universidade"
            };

            if (collegeDialog.ShowDialog() == true)
            {
                DbContextHelper.EditCollege(_db, collegeDialog.College);
            }
        }
Exemple #19
0
        public async Task GetEventListWithName(string nameOfEvent)
        {
            // Arrange
            using (var context = DbContextHelper.GetInMemoryDbContext())
            {
                var service         = new EventService(context);
                var searchParameter = new EventSearchParameter
                {
                    Name = nameOfEvent
                };

                // Act
                var events = await service.GetEventsAsync(searchParameter);

                // Assert
                Assert.True(!events.Any(x => !x.Name.StartsWith(nameOfEvent)));
            }
        }
Exemple #20
0
        public async Task GetPreviousSubmission_ThrowsInvalidOperationException_IfSpecifiedDataReturnVersionIsNotSavedInDatabase()
        {
            var dbHelper = new DbContextHelper();

            var weeeContext = A.Fake <WeeeContext>();

            A.CallTo(() => weeeContext.DataReturnVersions)
            .Returns(dbHelper.GetAsyncEnabledDbSet(new List <DataReturnVersion>()));

            DataReturnSubmissionsDataAccess dataAccess = new DataReturnSubmissionsDataAccess(weeeContext);

            var dataReturnVersion = A.Fake <DataReturnVersion>();

            A.CallTo(() => dataReturnVersion.IsSubmitted)
            .Returns(true);

            await Assert.ThrowsAsync <InvalidOperationException>(() => dataAccess.GetPreviousSubmission(dataReturnVersion));
        }
        public TssoUsercodeMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);
            // Properties
            this.Property(t => t.Id)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Usercode)
            .IsRequired();
            this.Property(t => t.Status)
            .IsRequired();

            // Table & Column Mappings
            this.ToTable("TSSO_USERCODE", DbContextHelper.GetOwnerByTableName("TSSO_USERCODE"));
            this.Property(t => t.Id).HasColumnName("ID");
            this.Property(t => t.Usercode).HasColumnName("USERCODE");
            this.Property(t => t.Status).HasColumnName("STATUS");
        }
Exemple #22
0
        public async Task Start(string sdkConnectionString, string connectionString, int maxParallelism, int numberOfWorkers)
        {
            _connectionString    = connectionString;
            _sdkConnectionString = sdkConnectionString;
            _container           = new WindsorContainer();
            _container.Install(
                new RebusHandlerInstaller()
                , new RebusInstaller(connectionString, maxParallelism, numberOfWorkers)
                );

            Core core = await _coreHelper.GetCore();

            _dbContextHelper = new DbContextHelper(connectionString);

            _container.Register(Component.For <Core>().Instance(core));
            _container.Register(Component.For <DbContextHelper>().Instance(_dbContextHelper));
            _bus = _container.Resolve <IBus>();
        }
Exemple #23
0
    public async Task ListRecursoTarefaQuery_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid sistemaId = Guid.NewGuid();
        await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId));

        Guid projetoId = Guid.NewGuid();
        await unitOfWork.ProjetoRepository.AddAsync(MockEntityHelper.GetNewProjeto(sistemaId, projetoId));

        Guid workflowId = Guid.NewGuid();
        await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow(workflowId));

        Guid recursoId = Guid.NewGuid();
        await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso(recursoId));

        Guid tipoTarefaId = Guid.NewGuid();
        await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa(tipoTarefaId));

        Guid tarefaId = Guid.NewGuid();
        await unitOfWork.TarefaRepository.AddAsync(MockEntityHelper.GetNewTarefa(projetoId, workflowId, recursoId, tipoTarefaId, tarefaId));

        Guid recursoTarefaId = Guid.NewGuid();
        await unitOfWork.RecursoTarefaRepository.AddAsync(MockEntityHelper.GetNewRecursoTarefa(tarefaId, recursoId, recursoTarefaId));

        await unitOfWork.RecursoTarefaRepository.AddAsync(MockEntityHelper.GetNewRecursoTarefa(tarefaId, recursoId));

        await unitOfWork.RecursoTarefaRepository.AddAsync(MockEntityHelper.GetNewRecursoTarefa(tarefaId, recursoId));

        await unitOfWork.SaveChangesAsync();

        ListRecursoTarefaQuery request = new();

        // Act
        RecursoTarefaHandler handler = new(unitOfWork, mapper);
        IEnumerable <RecursoTarefaViewModel> response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response != null);
        Assert.True(response.Any());
        Assert.True(response.FirstOrDefault(x => x.Id == recursoTarefaId) != null);
    }
Exemple #24
0
        public TpcnUepayconfigMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);
            // Properties
            this.Property(t => t.Id)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Typeid)
            .IsRequired();
            this.Property(t => t.Paycode)
            .IsRequired()
            .HasMaxLength(100);
            this.Property(t => t.Notifyurl)
            .IsOptional()
            .HasMaxLength(100);
            this.Property(t => t.Status)
            .IsRequired()
            .IsConcurrencyToken();
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(100);
            this.Property(t => t.Accesskeyid)
            .IsOptional()
            .HasMaxLength(50);
            this.Property(t => t.Accesssecret)
            .IsOptional()
            .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("TPCN_UEPAYCONFIG", DbContextHelper.GetOwnerByTableName("TPCN_UEPAYCONFIG"));
            this.Property(t => t.Id).HasColumnName("ID");
            this.Property(t => t.Typeid).HasColumnName("TYPEID");
            this.Property(t => t.Paycode).HasColumnName("PAYCODE");
            this.Property(t => t.Notifyurl).HasColumnName("NOTIFYURL");
            this.Property(t => t.Status).HasColumnName("STATUS");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
            this.Property(t => t.Accesskeyid).HasColumnName("ACCESSKEYID");
            this.Property(t => t.Accesssecret).HasColumnName("ACCESSSECRET");
        }
    public async Task UpdateProjetoCommand_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid sistemaId = Guid.NewGuid();

        await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId));

        Guid     projetoId    = Guid.NewGuid();
        DateTime dataInclusao = DateTime.Now;

        Projeto projeto = MockEntityHelper.GetNewProjeto(sistemaId, projetoId);

        await unitOfWork.ProjetoRepository.AddAsync(projeto);

        await unitOfWork.SaveChangesAsync();

        unitOfWork.ProjetoRepository.Detatch(projeto);

        UpdateProjetoCommand request = new()
        {
            Projeto = MockViewModelHelper.GetNewProjeto(sistemaId, projetoId, dataInclusao)
        };

        GetProjetoQuery request2 = new()
        {
            Id = projetoId
        };

        // Act
        ProjetoHandler  handler  = new(unitOfWork, mapper);
        OperationResult response = await handler.Handle(request, CancellationToken.None);

        ProjetoViewModel response2 = await handler.Handle(request2, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
        Assert.True(response2 != null);
        Assert.True(response2.Id == projetoId);
        Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks);
    }
}
        public TblUserJxsStockhis2Map()
        {
            // Primary Key
            this.HasKey(t => t.Hisid);
            // Properties
            this.Property(t => t.Hisid)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Infoid)
            .IsRequired();
            this.Property(t => t.Typeid)
            .IsRequired();
            this.Property(t => t.Nodeid)
            .IsRequired();
            this.Property(t => t.Amount)
            .IsRequired()
            .HasPrecision(12, 2);
            this.Property(t => t.Num)
            .IsRequired();
            this.Property(t => t.Totalamount)
            .IsRequired()
            .HasPrecision(12, 2);
            this.Property(t => t.Opnodeid)
            .IsRequired();
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("TBL_USER_JXS_STOCKHIS2", DbContextHelper.GetOwnerByTableName("TBL_USER_JXS_STOCKHIS2"));
            this.Property(t => t.Hisid).HasColumnName("HISID");
            this.Property(t => t.Infoid).HasColumnName("INFOID");
            this.Property(t => t.Typeid).HasColumnName("TYPEID");
            this.Property(t => t.Nodeid).HasColumnName("NODEID");
            this.Property(t => t.Amount).HasColumnName("AMOUNT");
            this.Property(t => t.Num).HasColumnName("NUM");
            this.Property(t => t.Totalamount).HasColumnName("TOTALAMOUNT");
            this.Property(t => t.Opnodeid).HasColumnName("OPNODEID");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
        }
    public async Task UpdateRecursoCommand_Handle()
    {
        // Arrange
        IUnitOfWork          unitOfWork = DbContextHelper.GetContext();
        IMapper              mapper     = AutoMapperHelper.GetMappings();
        ICryptographyManager manager    = CryptographyHelper.GetInstance();

        Guid     recursoId    = Guid.NewGuid();
        DateTime dataInclusao = DateTime.Now;

        Recurso recurso = MockEntityHelper.GetNewRecurso(recursoId);

        await unitOfWork.RecursoRepository.AddAsync(recurso);

        await unitOfWork.SaveChangesAsync();

        unitOfWork.RecursoRepository.Detatch(recurso);

        UpdateRecursoCommand request = new()
        {
            Recurso = MockViewModelHelper.GetNewRecurso(recursoId, dataInclusao)
        };

        GetRecursoQuery request2 = new()
        {
            Id = recursoId
        };

        // Act
        RecursoHandler  handler  = new(unitOfWork, mapper, manager);
        OperationResult response = await handler.Handle(request, CancellationToken.None);

        RecursoViewModel response2 = await handler.Handle(request2, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
        Assert.True(response2 != null);
        Assert.True(response2.Id == recursoId);
        Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks);
        Assert.True(response2.Senha == null);
        Assert.True(response2.Salt == null);
    }
}
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req,
            TraceWriter log)
        {
            OrderCreation creation = await req.Content.ReadAsAsync <OrderCreation>();

            var storeDB = new DbContextHelper().GetContext();

            var order = creation.OrderToCreate;

            //Save Order
            storeDB.Orders.Add(order);
            storeDB.SaveChanges();

            //Process the order
            decimal orderTotal = 0;


            // Iterate over the items in the cart, adding the order details for each
            foreach (var item in creation.CartItems)
            {
                var orderDetail = new OrderDetail
                {
                    AlbumId   = item.AlbumId,
                    OrderId   = order.OrderId,
                    UnitPrice = item.Album.Price,
                    Quantity  = item.Count
                };

                // Set the order total of the shopping cart
                orderTotal += (item.Count * item.Album.Price);

                storeDB.OrderDetails.Add(orderDetail);
            }

            // Set the order's total to the orderTotal count
            order.Total = orderTotal;

            // Save the order
            storeDB.SaveChanges();

            return(req.CreateResponse(HttpStatusCode.OK, order.OrderId));
        }
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            CollegeSubject employeeEdit = subjectGrd.SelectedItem as CollegeSubject;

            if (employeeEdit == null)
            {
                return;
            }
            CollegeSubjectDialog collegeSubjectDialog = new CollegeSubjectDialog(new CollegeSubject(employeeEdit))
            {
                Title = "Editar Curso"
            };

            if (collegeSubjectDialog.ShowDialog() == true)
            {
                DbContextHelper.EditSubject(_db, collegeSubjectDialog.CollegeSubject);
                subjectGrd.Items.Refresh();
            }
        }
Exemple #30
0
        /// <summary>
        /// Authorize the current user on the site. Authenication occurs via Facebook app (signin)
        /// </summary>
        /// <param name="model">User model</param>
        /// <param name="status">status of authorizing the user</param>
        /// <param name="code">Facebook Oauth code used to retrieve a Facebook access token</param>
        /// <returns></returns>
        /// <remarks>Requires the code to be set on the model. This is used to retrieve a Facebook access token</remarks>
        public static bool Authorize(this UserModel model, string code, out Status status)
        {
            try
            {
                using (var db = new DbContextHelper())
                {
                    // TODO: Validate the access token

                    var user = ManageUserModelHelper.GetUser(db, idKey: model.IdKey, email: model.Email, screenName: model.ScreenName, facebookId: model.FacebookId);
                    if (user == null)
                    {
                        return(model.Register(out status));
                    }

                    user.AccessToken    = model.AccessToken;
                    user.LastAccessed   = DateTime.Now;
                    user.UserStatusEnum = UserStatus.Online;
                    db.SaveChanges();

                    // Save the user basic information
                    model.Id         = user.Id;
                    model.IdKey      = user.IdKey;
                    model.ScreenName = user.ScreenName;
                    model.FirstName  = user.FirstName;
                    model.LastName   = user.LastName;
                    model.UserStatus = user.UserStatusEnum;
                    model.Roles      = user.Roles.ToList().GetRoleModelsFromRoles();

                    model.CreateAuthorizationTicket();

                    status = Status.Success;
                    return(true);
                }
            }

            catch (Exception ex)
            {
                LogHelper.LogFatalError("FacebookHelper.Authorize", ex);
                status = Status.SystemException;
            }

            return(false);
        }
Exemple #31
0
        public VnetProvinceMap()
        {
            this.HasKey(t => t.ProvinceId);
            // Properties
            this.Property(t => t.ProvinceId)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ProvinceName)
            .IsRequired();

            this.Property(t => t.Status)
            .IsRequired();

            // Table & Column Mappings
            this.ToTable("VNET_PROVINCE", DbContextHelper.GetOwnerByTableName("VNET_PROVINCE"));
            this.Property(t => t.ProvinceId).HasColumnName("PROVINCE_ID");
            this.Property(t => t.ProvinceName).HasColumnName("PROVINCE_NAME");
            this.Property(t => t.Status).HasColumnName("STATUS");
        }
    public async Task UpdateSistemaCommand_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Mock <IEventHandler> mockServiceBus           = ServiceBusHelper.GetInstance();
        Mock <IHubContext <CpnucleoHub> > mockSignalR = SignalRHelper.GetInstance();

        Guid     sistemaId    = Guid.NewGuid();
        DateTime dataInclusao = DateTime.Now;

        Sistema sistema = MockEntityHelper.GetNewSistema(sistemaId);

        await unitOfWork.SistemaRepository.AddAsync(sistema);

        await unitOfWork.SaveChangesAsync();

        unitOfWork.SistemaRepository.Detatch(sistema);

        UpdateSistemaCommand request = new()
        {
            Sistema = MockViewModelHelper.GetNewSistema(sistemaId, dataInclusao)
        };

        GetSistemaQuery request2 = new()
        {
            Id = sistemaId
        };

        // Act
        SistemaHandler  handler  = new(unitOfWork, mapper, mockServiceBus.Object, mockSignalR.Object);
        OperationResult response = await handler.Handle(request, CancellationToken.None);

        SistemaViewModel response2 = await handler.Handle(request2, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
        Assert.True(response2 != null);
        Assert.True(response2.Id == sistemaId);
        Assert.True(response2.DataInclusao.Ticks == dataInclusao.Ticks);
    }
}
    public async Task CreateRecursoCommand_Handle()
    {
        // Arrange
        IUnitOfWork          unitOfWork = DbContextHelper.GetContext();
        IMapper              mapper     = AutoMapperHelper.GetMappings();
        ICryptographyManager manager    = CryptographyHelper.GetInstance();

        CreateRecursoCommand request = new()
        {
            Recurso = MockViewModelHelper.GetNewRecurso()
        };

        // Act
        RecursoHandler  handler  = new(unitOfWork, mapper, manager);
        OperationResult response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response == OperationResult.Success);
    }
        public TpxinYaoyiyaoMap()
        {
            // Primary Key
            this.HasKey(t => t.Infoid);
            // Properties
            this.Property(t => t.Infoid)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.Createtime)
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.Nodeid)
            .IsRequired();
            this.Property(t => t.Createtime)
            .IsRequired();
            this.Property(t => t.Remarks)
            .IsOptional()
            .HasMaxLength(100);
            this.Property(t => t.Status)
            .IsRequired();
            this.Property(t => t.Photo)
            .IsRequired()
            .HasMaxLength(150);
            this.Property(t => t.Nickname)
            .IsRequired()
            .HasMaxLength(100);
            this.Property(t => t.Longitude)
            .IsRequired()
            .HasMaxLength(100);
            this.Property(t => t.Latitude)
            .IsRequired()
            .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("TPXIN_YAOYIYAO", DbContextHelper.GetOwnerByTableName("TPXIN_YAOYIYAO"));
            this.Property(t => t.Infoid).HasColumnName("INFOID");
            this.Property(t => t.Nodeid).HasColumnName("NODEID");
            this.Property(t => t.Createtime).HasColumnName("CREATETIME");
            this.Property(t => t.Remarks).HasColumnName("REMARKS");
            this.Property(t => t.Status).HasColumnName("STATUS");
            this.Property(t => t.Photo).HasColumnName("PHOTO");
            this.Property(t => t.Nickname).HasColumnName("NICKNAME");
            this.Property(t => t.Longitude).HasColumnName("LONGITUDE");
            this.Property(t => t.Latitude).HasColumnName("LATITUDE");
        }
Exemple #35
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            CIMOBProject.Models.Application applicationEdit = applicationGrd.SelectedItem as CIMOBProject.Models.Application;
            if (applicationEdit == null)
            {
                return;
            }
            ApplicationDialog applicationDialog = new ApplicationDialog(new CIMOBProject.Models.Application(applicationEdit))
            {
                Title = "Editar Estado Candidatura"
            };

            if (applicationDialog.ShowDialog() == true)
            {
                DbContextHelper.EditApplication(_db, applicationDialog.Application);
                //Refresh needed to update virtual properties.
                applicationGrd.Items.Refresh();
            }
        }
Exemple #36
0
    public async Task GetRecursoTarefaQuery_Handle()
    {
        // Arrange
        IUnitOfWork unitOfWork = DbContextHelper.GetContext();
        IMapper     mapper     = AutoMapperHelper.GetMappings();

        Guid sistemaId = Guid.NewGuid();
        await unitOfWork.SistemaRepository.AddAsync(MockEntityHelper.GetNewSistema(sistemaId));

        Guid projetoId = Guid.NewGuid();
        await unitOfWork.ProjetoRepository.AddAsync(MockEntityHelper.GetNewProjeto(sistemaId, projetoId));

        Guid workflowId = Guid.NewGuid();
        await unitOfWork.WorkflowRepository.AddAsync(MockEntityHelper.GetNewWorkflow(workflowId));

        Guid recursoId = Guid.NewGuid();
        await unitOfWork.RecursoRepository.AddAsync(MockEntityHelper.GetNewRecurso(recursoId));

        Guid tipoTarefaId = Guid.NewGuid();
        await unitOfWork.TipoTarefaRepository.AddAsync(MockEntityHelper.GetNewTipoTarefa(tipoTarefaId));

        Guid tarefaId = Guid.NewGuid();
        await unitOfWork.TarefaRepository.AddAsync(MockEntityHelper.GetNewTarefa(projetoId, workflowId, recursoId, tipoTarefaId, tarefaId));

        Guid recursoTarefaId = Guid.NewGuid();
        await unitOfWork.RecursoTarefaRepository.AddAsync(MockEntityHelper.GetNewRecursoTarefa(tarefaId, recursoId, recursoTarefaId));

        await unitOfWork.SaveChangesAsync();

        GetRecursoTarefaQuery request = new()
        {
            Id = recursoTarefaId
        };

        // Act
        RecursoTarefaHandler   handler  = new(unitOfWork, mapper);
        RecursoTarefaViewModel response = await handler.Handle(request, CancellationToken.None);

        // Assert
        Assert.True(response != null);
        Assert.True(response.Id != Guid.Empty);
        Assert.True(response.DataInclusao.Ticks != 0);
    }
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            // security context
            builder.RegisterType <SecurityContextProvider>()
            .As <ISecurityContext>()
            .As <ISecurityContextPrincipal>()
            .InstancePerLifetimeScope();

            builder.Register(x =>
                             DbContextHelper.BuildDbContext <IdentityServerDbContext>(
                                 x.ResolveKeyed <string>("MainDbConnectionString")))
            .SingleInstance();

            builder.RegisterType <UserRepository>()
            .AsImplementedInterfaces()
            .SingleInstance();
        }
        public async Task GetOrAddAatfDeliveryLocation_PopulatesCacheWithDatabaseValues(string approvalNumber, string facilityName)
        {
            // Arrange
            var dbContextHelper = new DbContextHelper();
            var context = A.Fake<WeeeContext>();

            var aatfDeliveryLocationDb = new AatfDeliveryLocation(approvalNumber, facilityName);
            var aatfDeliveryLocations = dbContextHelper.GetAsyncEnabledDbSet(new List<AatfDeliveryLocation> { aatfDeliveryLocationDb });
            A.CallTo(() => context.AatfDeliveryLocations)
                .Returns(aatfDeliveryLocations);

            var dataAccess = new DataReturnVersionBuilderDataAccess(A.Dummy<Scheme>(), A.Dummy<Quarter>(), context);

            // Act
            await dataAccess.GetOrAddAatfDeliveryLocation(approvalNumber, facilityName);

            // Assert
            Assert.Equal(1, dataAccess.CachedAatfDeliveryLocations.Count);
            Assert.Contains(aatfDeliveryLocationDb, dataAccess.CachedAatfDeliveryLocations.Values);
        }
        public async Task GetOrAddAatfDeliveryLocation_WithMatchingApprovalNumberAndFacilityName_DoesNotAddToCacheAndDatabase(string approvalNumber, string facilityName)
        {
            // Arrange
            var dbContextHelper = new DbContextHelper();
            var context = A.Fake<WeeeContext>();

            var aatfDeliveryLocationDb = new AatfDeliveryLocation(approvalNumber, facilityName);
            var aatfDeliveryLocations = dbContextHelper.GetAsyncEnabledDbSet(new List<AatfDeliveryLocation> { aatfDeliveryLocationDb });
            A.CallTo(() => context.AatfDeliveryLocations)
                .Returns(aatfDeliveryLocations);

            var dataAccess = new DataReturnVersionBuilderDataAccess(A.Dummy<Scheme>(), A.Dummy<Quarter>(), context);

            // Act
            var result = await dataAccess.GetOrAddAatfDeliveryLocation(approvalNumber, facilityName);

            // Assert
            Assert.Equal(1, dataAccess.CachedAatfDeliveryLocations.Count);
            A.CallTo(() => aatfDeliveryLocations.Add(result))
                .MustNotHaveHappened();
        }
 public UpdateCompetentAuthorityUserRoleAndStatusDataAccessTests()
 {
     context = A.Fake<WeeeContext>();
     helper = new DbContextHelper();
 }
 public GetSchemeStatusHandlerTests()
 {
     contextHelper = new DbContextHelper();
     context = A.Fake<WeeeContext>();
     mapper = A.Fake<IMap<Domain.Scheme.SchemeStatus, SchemeStatus>>();
 }
        private WeeeContext MakeFakeWeeeContext(IUserContext userContext,
                                                Guid? userId = null,
                                                List<OrganisationUser> organisationUsers = null,
                                                List<Domain.Scheme.Scheme> schemes = null,
                                                bool userStatusActive = true,
                                                List<CompetentAuthorityUser> competentAuthorityUsers = null)
        {
            userId = userId ?? Guid.NewGuid();

            organisationUsers = organisationUsers ?? new List<OrganisationUser>();
            schemes = schemes ?? new List<Domain.Scheme.Scheme>();
            competentAuthorityUsers = competentAuthorityUsers ?? new List<CompetentAuthorityUser>
            {
                new CompetentAuthorityUser(userId.ToString(), Guid.NewGuid(), userStatusActive ? UserStatus.Active : UserStatus.Inactive, A.Dummy<Role>())
            };

            var dbHelper = new DbContextHelper();
            WeeeContext weeeContext = A.Fake<WeeeContext>();
            A.CallTo(() => weeeContext.OrganisationUsers).Returns(dbHelper.GetAsyncEnabledDbSet(organisationUsers));
            A.CallTo(() => weeeContext.Schemes).Returns(dbHelper.GetAsyncEnabledDbSet(schemes));
            A.CallTo(() => weeeContext.CompetentAuthorityUsers).Returns(dbHelper.GetAsyncEnabledDbSet(competentAuthorityUsers));

            A.CallTo(() => userContext.UserId).Returns(userId.Value);

            return weeeContext;
        }
 public SetSchemeStatusHandlerTests()
 {
     context = A.Fake<WeeeContext>();
     dbContextHelper = new DbContextHelper();
 }
        public async Task GetOrAddAeDeliveryLocation_IgnoresCaseOfApprovalNumberAndOperatorName()
        {
            // Arrange
            var dbContextHelper = new DbContextHelper();
            var context = A.Fake<WeeeContext>();

            var aeDeliveryLocations = dbContextHelper.GetAsyncEnabledDbSet(new List<AeDeliveryLocation>());
            A.CallTo(() => context.AeDeliveryLocations)
                .Returns(aeDeliveryLocations);

            var dataAccess = new DataReturnVersionBuilderDataAccess(A.Dummy<Scheme>(), A.Dummy<Quarter>(), context);

            // Act
            var result1 = await dataAccess.GetOrAddAeDeliveryLocation("AAA", "BBB");
            var result2 = await dataAccess.GetOrAddAeDeliveryLocation("aaa", "BBB");
            var result3 = await dataAccess.GetOrAddAeDeliveryLocation("AAA", "bbb");
            var result4 = await dataAccess.GetOrAddAeDeliveryLocation("aaa", "bbb");

            // Assert
            Assert.Contains(result1, dataAccess.CachedAeDeliveryLocations.Values);
            Assert.Same(result1, result2);
            Assert.Same(result1, result3);
            Assert.Same(result1, result4);
            A.CallTo(() => aeDeliveryLocations.Add(A<AeDeliveryLocation>._))
                .MustHaveHappened(Repeated.Exactly.Once);
        }
 public UpdateUserHandlerTests()
 {
     userHelper = new UserHelper();
     helper = new DbContextHelper();
 }