Пример #1
0
        private static void GetLicense(LicenseCategory licenseCategory)
        {
            LicenseClient licenseClient = new LicenseClient(LicenseClient.PublicKeyXmlFromAssembly(Assembly.GetExecutingAssembly()));

            try
            {
                LicensePublisherResponse response = licenseClient.GetLicense(
                    Product,
                    Assembly.GetExecutingAssembly().GetName().Version,
                    s_licenseKeys[(int)licenseCategory],
                    licenseCategory.ToString(),
                    "Test User",
                    "Test Company",
                    "*****@*****.**",
                    MachineLicense.LocalMachineData);
                License license = response.License;
                if (license == null)
                {
                    Console.WriteLine("ERROR: " + response.ErrorMessage);
                }
                else
                {
                    File.WriteAllText(Assembly.GetExecutingAssembly().Location + ".lic", license.SignedString);
                    LicenseManager.Reset();
                }

                licenseClient.Close();
            }
            catch (CommunicationException exception)
            {
                Console.WriteLine("EXCEPTION: " + exception.Message);
                licenseClient.Abort();
            }
        }
        public async Task InsertLicenseCategory()
        {
            var options = TestHelper.GetDbContext("InsertLicenseCategory");

            //Given
            var model = new LicenseCategory()
            {
                Name = "1",
                Code = "A",
            };

            using (var context = new DataContext(options))
            {
                var service = new DirectoryLookupService(context);

                //When
                var result = await service.InsertLicenseCategory(model);

                //Then
                Assert.True(result.Success);

                var actual = await context.LicenseCategory.FindAsync(((LicenseCategory)result.Tag).Id);

                Assert.Equal(model.Name, actual.Name);
                Assert.Equal(model.Code, actual.Code);
            }
        }
        public async Task LicenseCategories()
        {
            var licenseCategory = new LicenseCategory()
            {
                Id   = Guid.NewGuid(),
                Name = "Name1",
                Code = "Code1",
            };

            var licenseCategories = new List <LicenseCategory>()
            {
                licenseCategory
            };

            var service = new Mock <IDirectoryLookupService>();

            service.Setup(c => c.GetLicenseCategories())
            .ReturnsAsync(licenseCategories);

            var controller = new LookupsController(service.Object);

            var result = await controller.LicenseCategories();

            var okResult    = Assert.IsType <OkObjectResult>(result);
            var returnValue = Assert.IsType <List <LicenseCategory> >(okResult.Value);

            Assert.Same(licenseCategories, returnValue);
        }
 public async Task AddTicketAsync(LicenseCategory licenseCategory)
 {
     {
         if (licenseCategory != null)
         {
             await _repository.Insert(licenseCategory);
         }
     }
 }
        public async Task <IActionResult> InsertLicenseCategory([FromBody] LicenseCategory model)
        {
            var result = await LookupService.InsertLicenseCategory(model);

            if (!result.Success)
            {
                return(BadRequest(result.ValidationFailures));
            }

            return(Ok(result));
        }
Пример #6
0
        private LicenseCategoryEntity MapLicenseCategoryModelToEntity(LicenseCategory model, LicenseCategoryEntity entity = null)
        {
            if (entity == null)
            {
                entity = new LicenseCategoryEntity();
            }

            entity.Code = model.Code;
            entity.Name = model.Name;

            return(entity);
        }
Пример #7
0
        public void AddCategoryToLicense(IPerson person, LicenseCategory categ)
        {
            if (person.License.OwnedCategories == null)
            {
                person.License.OwnedCategories = new SortedSet <LicenseCategory>();
            }

            if (!person.License.OwnedCategories.Contains(categ))
            {
                person.License.OwnedCategories.Add(categ);
            }
        }
Пример #8
0
        public async Task <Result> InsertLicenseCategory(LicenseCategory model)
        {
            var validator = new LicenseCategoryValidator(true);
            var result    = validator.Validate(model).GetResult();

            if (!result.Success)
            {
                return(result);
            }

            var entity = MapLicenseCategoryModelToEntity(model);
            await _context.LicenseCategory.AddAsync(entity);

            await _context.SaveChangesAsync();

            model.Id   = entity.Id;
            result.Tag = model;

            return(result);
        }
Пример #9
0
        public async Task <Result> UpdateLicenseCategory(LicenseCategory model)
        {
            var validator = new LicenseCategoryValidator(false);
            var result    = validator.Validate(model).GetResult();

            if (!result.Success)
            {
                return(result);
            }

            var entity = await _context.LicenseCategory.FindAsync(model.Id);

            if (entity == null)
            {
                return(new Result());
            }

            entity = MapLicenseCategoryModelToEntity(model, entity);
            await _context.SaveChangesAsync();

            return(result);
        }
Пример #10
0
        public async Task UpdateLicenseCategory()
        {
            var options = TestHelper.GetDbContext("UpdateLicenseCategory");

            //Given
            var lkp1 = new LicenseCategoryEntity {
                Id = Guid.NewGuid(), Name = "1", Code = "A"
            };

            using (var context = new DataContext(options))
            {
                context.LicenseCategory.Add(lkp1);

                context.SaveChanges();
            }

            var model = new LicenseCategory()
            {
                Id   = lkp1.Id,
                Name = "1 Updated",
                Code = "A Updated",
            };

            using (var context = new DataContext(options))
            {
                var service = new DirectoryLookupService(context);

                //When
                var result = await service.UpdateLicenseCategory(model);

                //Then
                Assert.True(result.Success);

                var actual = await context.LicenseCategory.FindAsync(model.Id);

                Assert.Equal(model.Name, actual.Name);
                Assert.Equal(model.Code, actual.Code);
            }
        }
        public async Task UpdateLicenseCategory()
        {
            var licenseCategory = new LicenseCategory()
            {
                Id   = Guid.NewGuid(),
                Name = "Name1",
                Code = "Code1"
            };

            var service = new Mock <IDirectoryLookupService>();

            var result = new Result()
            {
                Success = true
            };

            LicenseCategory updated = null;

            service.Setup(c => c.UpdateLicenseCategory(It.IsAny <LicenseCategory>()))
            .Callback((LicenseCategory i) =>
            {
                updated = i;
            })
            .ReturnsAsync(result);

            var controller = new LookupsController(service.Object);

            var actual = await controller.UpdateLicenseCategory(licenseCategory.Id.Value, licenseCategory);

            Assert.Same(licenseCategory, updated);

            var okResult    = Assert.IsType <OkObjectResult>(actual);
            var returnValue = Assert.IsType <Result>(okResult.Value);

            Assert.Same(result, returnValue);
        }
        public async Task All()
        {
            var company = new Company()
            {
                Id = Guid.NewGuid(), Name = "Name2"
            };
            var userType = new UserType()
            {
                Id = Guid.NewGuid(), Name = "Name2"
            };
            var adviceScope = new AdviceScope()
            {
                Id = Guid.NewGuid(), Name = "Name2"
            };
            var adviceService = new AdviceService()
            {
                Id = Guid.NewGuid(), Name = "Name2"
            };
            var licenseCategory = new LicenseCategory()
            {
                Id = Guid.NewGuid(), Name = "Name2"
            };

            var companies = new List <Company>()
            {
                company
            };
            var userTypes = new List <UserType>()
            {
                userType
            };
            var licenseCategories = new List <LicenseCategory>()
            {
                licenseCategory
            };
            var adviceServices = new List <AdviceService>()
            {
                adviceService
            };
            var adviceScopes = new List <AdviceScope>()
            {
                adviceScope
            };

            var service = new Mock <IDirectoryLookupService>();

            service.Setup(c => c.GetCompanies()).ReturnsAsync(companies);
            service.Setup(c => c.GetUserTypes()).ReturnsAsync(userTypes);
            service.Setup(c => c.GetLicenseCategories()).ReturnsAsync(licenseCategories);
            service.Setup(c => c.GetAdviceServices()).ReturnsAsync(adviceServices);
            service.Setup(c => c.GetAdviceScopes()).ReturnsAsync(adviceScopes);

            var controller = new LookupsController(service.Object);

            var result = await controller.All();

            var okResult    = Assert.IsType <OkObjectResult>(result);
            var returnValue = Assert.IsType <api.Controllers.Directory.Lookups.Dto.Lookups>(okResult.Value);

            var all = new api.Controllers.Directory.Lookups.Dto.Lookups()
            {
                Companies         = companies,
                UserTypes         = userTypes,
                LicenseCategories = licenseCategories,
                AdviceScopes      = adviceScopes,
                AdviceServices    = adviceServices,
            };

            Assert.NotStrictEqual(all, returnValue);
        }
Пример #13
0
        public async Task <IActionResult> UpdateLicenseCategory(Guid licenseCategoryId, [FromBody] LicenseCategory model)
        {
            model.Id = licenseCategoryId;

            var result = await LookupService.UpdateLicenseCategory(model);

            if (!result.Success)
            {
                return(BadRequest(result.ValidationFailures));
            }

            return(Ok(result));
        }
Пример #14
0
 public void CreateALicense(IPerson person, LicenseCategory categ)
 {
     person.License = Factory.CreateBruteLicense();
     AddCategoryToLicense(person, categ);
 }