private void CreateUserRecords()
        {
            var userGroup = new UserGroup()
            {
                Domain     = Domain,
                Name       = "UserGroup",
                AdObjectId = Guid.NewGuid()
            };

            GeneralUser1 = new GeneralUser()
            {
                AccountName = "GeneralUser1",
                Name        = "GU1",
                Domain      = Domain,
                AuthenticateWhenUnlockingScreen = true,
                AdObjectId = Guid.NewGuid()
            };

            var availablePeriod = new AvailablePeriod()
            {
                EndUser   = GeneralUser1,
                StartDate = CurrentDateTimeForStart.Item1,
                EndDate   = CurrentDateTimeForStart.Item2
            };

            var userGroupEndUser = new UserGroupEndUser()
            {
                UserGroup = userGroup,
                EndUser   = GeneralUser1
            };

            MainDbContext.AddRange(userGroup, GeneralUser1, availablePeriod, userGroupEndUser);
        }
        public object UpdatePeriodByProperty([FromBody] UpdatePeriodDTO updatePeriodDTO)
        {
            RealEstate property = null;

            if (ModelState.IsValid && this._service.GetAll().Any(e => e.Name.ToLower() == updatePeriodDTO.name.ToLower()))
            {
                property = this._service.GetPropertyByName(updatePeriodDTO.name);

                var availablePeriod = new AvailablePeriod(
                    updatePeriodDTO.startDate,
                    updatePeriodDTO.endDate,
                    updatePeriodDTO.amount,
                    updatePeriodDTO.currency);
                availablePeriod.PropertyName = property.Name;

                property.Calendar.Add(availablePeriod);
            }

            return(property);
        }
        public void Case06()
        {
            var org1    = Utils.CreateOrganization(code: 1, name: "org1", startDate: DateTime.Today, endDate: DateTime.Today);
            var domain1 = new Domain {
                Id = Guid.NewGuid(), Name = "domain1", Organization = org1
            };
            var user1 = new UserAdmin {
                AccountName = "user1", Name = "", Domain = domain1, Password = Utils.HashPassword("user1")
            };
            var availablePeriod1 = new AvailablePeriod {
                StartDate = DateTime.Today, EndDate = DateTime.Today, EndUser = user1
            };

            _context.AddRange(org1, domain1, user1, availablePeriod1);
            _context.SaveChanges();

            var query    = new { organizationCode = 1, domainName = "domain1", userName = "******", password = "******" };
            var response = _client.PostAsync(LoginUrl, Utils.CreateJsonContent(query)).Result;

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
        public ListingMineTests(CustomWebApplicationFactory <JinCreek.Server.Admin.Startup> factory)
        {
            _client  = factory.CreateClient();
            _context = factory.Services.GetService <IServiceScopeFactory>().CreateScope().ServiceProvider.GetService <MainDbContext>();

            Utils.RemoveAllEntities(_context);

            _context.Add(_org1    = Utils.CreateOrganization(code: 1, name: "org1"));
            _context.Add(_org2    = Utils.CreateOrganization(code: 2, name: "org2"));
            _context.Add(_domain1 = new Domain {
                Id = Guid.NewGuid(), Name = "domain01", Organization = _org1
            });
            _context.Add(_domain2 = new Domain {
                Id = Guid.NewGuid(), Name = "domain02", Organization = _org2
            });
            _context.Add(_user1 = new SuperAdmin {
                AccountName = "user0", Password = Utils.HashPassword("user0")
            });                                                                                                      // スーパー管理者
            _context.Add(_user2 = new UserAdmin()
            {
                AccountName = "user1", Password = Utils.HashPassword("user1"), Domain = _domain1
            });                                                                                                                          // ユーザー管理者
            _context.Add(_deviceGroup1 = new DeviceGroup()
            {
                Id = Guid.NewGuid(), Name = "_deviceGroup1", Domain = _domain1
            });
            _context.Add(_lte1 = new LteModule()
            {
                Name = "lte1", UseSoftwareRadioState = true, NwAdapterName = "abc"
            });
            _context.Add(_userGroup1 = new UserGroup {
                Id = Guid.NewGuid(), Domain = _domain1, Name = "userGroup1"
            });
            _context.Add(_userGroupEndUser = new UserGroupEndUser()
            {
                EndUser = _user2, UserGroup = _userGroup1
            });
            _context.Add(_availablePeriod = new AvailablePeriod()
            {
                EndUser = _user2, EndDate = null, StartDate = DateTime.Today
            });
            _context.Add(_simGroup1 = new SimGroup()
            {
                Id                      = Guid.NewGuid(),
                Name                    = "simGroup1",
                Organization            = _org1,
                Apn                     = "apn",
                AuthenticationServerIp  = "AuthServerIpAddress",
                IsolatedNw1IpPool       = "Nw1IpAddressPool",
                IsolatedNw1SecondaryDns = "Nw1SecondaryDns",
                IsolatedNw1IpRange      = "Nw1IpAddressRange",
                IsolatedNw1PrimaryDns   = "Nw1PrimaryDns",
                NasIp                   = "NasIpAddress",
                UserNameSuffix          = "UserNameSuffix",
                PrimaryDns              = "PrimaryDns",
                SecondaryDns            = "SecondaryDns"
            });
            _context.Add(_simGroup2 = new SimGroup
            {
                Id = Guid.NewGuid(), Name = "simGroup2", Organization = _org2, IsolatedNw1IpPool = ""
            });
            _context.Add(_sim1 = new Sim() // 組織 : '自組織
            {
                Msisdn   = "msisdn01",
                Imsi     = "imsi01",
                IccId    = "iccid01",
                UserName = "******",
                Password = "******",
                SimGroup = _simGroup1
            });
            _context.Add(_sim1a = new Sim() // 組織 : '自組織
            {
                Msisdn   = "msisdn01a",
                Imsi     = "imsi01a",
                IccId    = "iccid01a",
                UserName = "******",
                Password = "******",
                SimGroup = _simGroup1
            });
            _context.Add(_sim2 = new Sim() // 組織 : '他組織
            {
                Msisdn   = "msisdn02",
                Imsi     = "imsi02",
                IccId    = "iccid02",
                UserName = "******",
                Password = "******",
                SimGroup = _simGroup2
            });
            _context.Add(_device1 = new Device()
            {
                LteModule     = _lte1,
                Domain        = _domain1,
                Name          = "device01",
                UseTpm        = true,
                ManagedNumber = "001",
                WindowsSignInListCacheDays = 1,
            });
            _context.Add(_device2 = new Device()
            {
                LteModule     = _lte1,
                Domain        = _domain1,
                Name          = "device02",
                UseTpm        = true,
                ManagedNumber = "001",
                WindowsSignInListCacheDays = 1,
            });
            _context.SaveChanges();
        }
        public UpdateTests(CustomWebApplicationFactory <JinCreek.Server.Admin.Startup> factory)
        {
            _client  = factory.CreateClient();
            _context = factory.Services.GetService <IServiceScopeFactory>().CreateScope().ServiceProvider.GetService <MainDbContext>();

            Utils.RemoveAllEntities(_context);

            _context.Add(_org1    = Utils.CreateOrganization(code: 1, name: "org1"));
            _context.Add(_org2    = Utils.CreateOrganization(code: 2, name: "org2"));
            _context.Add(_domain1 = new Domain {
                Id = Guid.NewGuid(), Name = "domain01", Organization = _org1
            });
            _context.Add(_domain2 = new Domain {
                Id = Guid.NewGuid(), Name = "domain02", Organization = _org2
            });
            _context.Add(_userGroup1 = new UserGroup {
                Id = Guid.NewGuid(), Name = "userGroup1", Domain = _domain1
            });
            _context.Add(_userGroup2 = new UserGroup {
                Id = Guid.NewGuid(), Name = "userGroup2", Domain = _domain2
            });

            _context.Add(_user1 = new SuperAdmin {
                AccountName = "user0", Password = Utils.HashPassword("user0")
            });                                                                                                      // スーパー管理者
            _context.Add(_user2 = new UserAdmin()
            {
                AccountName = "user1", Password = Utils.HashPassword("user1"), Domain = _domain1
            });                                                                                                                          // ユーザー管理者
            _context.Add(_user3 = new GeneralUser()
            {
                AccountName = "user2", DomainId = _domain1.Id
            });
            _context.Add(_availablePeriod = new AvailablePeriod()
            {
                EndUser = _user2, EndDate = DateTime.Parse("2021-03-01"), StartDate = DateTime.Parse("2020-02-10")
            });
            _context.Add(_availablePeriod = new AvailablePeriod()
            {
                EndUser = _user3, EndDate = DateTime.Parse("2021-03-01"), StartDate = DateTime.Parse("2020-02-10")
            });
            _context.Add(_simGroup1 = new SimGroup()
            {
                Id                      = Guid.NewGuid(),
                Name                    = "simGroup1",
                Organization            = _org1,
                Apn                     = "apn",
                AuthenticationServerIp  = "AuthenticationServerIp",
                IsolatedNw1IpPool       = "IsolatedNw1IpPool",
                IsolatedNw1SecondaryDns = "IsolatedNw1SecondaryDns",
                IsolatedNw1IpRange      = "IsolatedNw1IpRange",
                IsolatedNw1PrimaryDns   = "IsolatedNw1PrimaryDns",
                NasIp                   = "NasIp",
                PrimaryDns              = "PrimaryDns",
                SecondaryDns            = "SecondaryDns"
            });
            _context.Add(_simGroup2 = new SimGroup
            {
                Id = Guid.NewGuid(), Name = "simGroup2", Organization = _org2, IsolatedNw1IpPool = ""
            });
            _context.Add(_sim1 = new Sim() // 組織 : '自組織
            {
                Msisdn   = "msisdn01",
                Imsi     = "imsi01",
                IccId    = "iccid01",
                UserName = "******",
                Password = "******",
                SimGroup = _simGroup1
            });
            _context.Add(_device1 = new Device()
            {
                LteModule     = null,
                Domain        = _domain1,
                Name          = "device01",
                UseTpm        = true,
                ManagedNumber = "001",
                WindowsSignInListCacheDays = 1,
            });
            _context.Add(_simDevice1 = new SimAndDevice()
            {
                Sim                    = _sim1,
                Device                 = _device1,
                IsolatedNw2Ip          = "127.0.0.1/18",
                AuthenticationDuration = 1,
                StartDate              = DateTime.Parse("2020-02-01"),
                EndDate                = DateTime.Parse("2021-02-01")
            });
            _context.Add(_multiFactor1 = new MultiFactor
            {
                SimAndDeviceId = _simDevice1.Id,
                EndUserId      = _user3.Id,
                ClosedNwIp     = "127.0.0.1",
                StartDate      = DateTime.Now,
                EndDate        = DateTime.Now
            });
            _context.SaveChanges();
        }