Beispiel #1
0
        public void InitializeData()
        {
            xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_500.xml");
            var tpa        = new TPAScaffold();
            var serializer = new XmlSerializer(tpa.GetType());

            input                   = (TPAScaffold)serializer.Deserialize(xmlReader);
            accountInfo             = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            accountService          = new AccountService(accountInfo.Webservice, accountInfo.UserName, accountInfo.Password, accountInfo.AccountNumber, accountInfo.LicenseKey, accountInfo.ERPName);
            createCompanyController = new CreateCompanyController();
            createCompanyController.TempData.Add("AccountInfo", accountInfo);
            createCompanyController.TempData.Add("AccountService", accountService);

            createCompany = new CreateCompany();
            createCompany.AccountInfoID = accountInfo.ID;
            createCompany.AddressLine1  = "900 winslow way e";
            createCompany.AddressLine2  = "";
            createCompany.AddressLine3  = "";
            createCompany.CompanyCode   = Guid.NewGuid().ToString().Substring(0, 8);
            createCompany.CompanyName   = "Systems of America1";
            createCompany.Country       = "US";
            createCompany.StateProvince = "WA";
            createCompany.TIN           = "95-3657472";

            createCompany.FirstName    = "abbott";
            createCompany.LastName     = "abbott";
            createCompany.PhoneNumber  = "9999999999";
            createCompany.Fax          = "9999999999";
            createCompany.Email        = "*****@*****.**";
            createCompany.City         = "Bainbridge Island";
            createCompany.ZipCode      = "98110";
            createCompany.MobileNumber = "";
            createCompany.Title        = "";
            createCompany.BIN          = "";
        }
Beispiel #2
0
        static void chooseFactory(int id)
        {
            int level = judgeLevel(id);

            if (level == 1) //省级公司
            {
                IFactory      cpyFactory    = new ProvinceFactory();
                CreateCompany createCompany = cpyFactory.createcompany();
                createCompany.CompanyID    = id;
                createCompany.CompanyName  = CompanyName;
                createCompany.Childcompany = DBhelper.GetChildcompany(id);
                createCompany.createword();
            }
            else if (level == 2) //市级公司
            {
                IFactory      cpyFactory    = new CityFactory();
                CreateCompany createCompany = cpyFactory.createcompany();
                createCompany.CompanyID    = id;
                createCompany.CompanyName  = CompanyName;
                createCompany.Childcompany = DBhelper.GetChildcompany(id);
                createCompany.createword();
            }
            else if (level == 3) //县级公司
            {
                IFactory      cpyFactory    = new CountryFactory();
                CreateCompany createCompany = cpyFactory.createcompany();
                createCompany.CompanyID    = id;
                createCompany.CompanyName  = CompanyName;
                createCompany.Childcompany = DBhelper.GetChildcompany(id);
                createCompany.createword();
            }
        }
Beispiel #3
0
        public async Task AddCompany([FromBody] CompanyRead companyRead)
        {
            var createCompany = new CreateCompany
            {
                DataId                 = new Guid(),
                Address                = companyRead.Address,
                Name                   = companyRead.Name,
                CreationTime           = companyRead.CreationTime,
                CompanyId              = companyRead.CompanyId,
                CreateCompanyTimeStamp = DateTime.Now.Ticks
            };
            var createCompanyName = new CreateCompanyName
            {
                CompanyId = companyRead.CompanyId,
                Name      = companyRead.Name,
                CreateCompanyNameTimeStamp = DateTime.Now.Ticks
            };

            var createCompanyAddress = new CreateCompanyAddress
            {
                CompanyId = companyRead.CompanyId,
                Address   = companyRead.Address,
                CreateCompanyAddressTimeStamp = DateTime.Now.Ticks
            };

            await _endpointInstance.Send(Helpers.ServerEndpoint, createCompany).ConfigureAwait(false);

            await _endpointInstance.Send(Helpers.ServerEndpoint, createCompanyName).ConfigureAwait(false);

            await _endpointInstance.Send(Helpers.ServerEndpoint, createCompanyAddress).ConfigureAwait(false);
        }
Beispiel #4
0
        private void createWord(int id)
        {
            //int level = judgeLevel(id);
            int           level         = CompanyManager.getSingleton().GetCompanyLevel(id) + 1;
            CreateCompany createCompany = null;

            if (level == 1) //省级公司
            {
                createCompany = DocFactory.createcompany(DocCompanyType.Provice, docCompilationListener);
            }
            else if (level == 2) //市级公司
            {
                createCompany = DocFactory.createcompany(DocCompanyType.City, docCompilationListener);
            }
            else if (level == 3) //县级公司
            {
                createCompany = DocFactory.createcompany(DocCompanyType.Country, docCompilationListener);
            }

            if (createCompany == null)
            {
                return;
            }

            createCompany.CompanyID    = id;
            createCompany.CompanyName  = CompanyName;
            createCompany.Childcompany = DBhelper.GetChildcompany(id);
            createCompany.createword(WordPath);
        }
Beispiel #5
0
        public virtual async Task <int> UpdateCompany(CreateCompanyOrContact input)
        {
            var data = _NewCompanyRepository.GetAll().Where(p => p.Name == input.Name && p.NewCustomerTypeId == input.NewCustomerTypeId && p.Id != input.Id).ToList();

            if (data.Count == 0)
            {
                if (input.ApprovedById == 0)
                {
                    input.ApprovedById = null;
                }

                CreateCompany company = new CreateCompany()
                {
                    Id   = input.Id,
                    Name = input.Name,
                    NewCustomerTypeId = input.NewCustomerTypeId ?? null,
                    AccountManagerId  = input.AccountManagerId ?? null,
                    CustomerId        = input.CustomerId,
                    ApprovedById      = input.ApprovedById ?? null,
                    IsApproved        = input.IsApproved,
                    TradeLicense      = input.TradeLicense,
                    TRNnumber         = input.TRNnumber,
                    IndustryId        = input.IndustryId ?? null,
                    Discountable      = input.Discountable,
                    UnDiscountable    = input.UnDiscountable
                };
                var companys = await _NewCompanyRepository.GetAsync(input.Id);

                ObjectMapper.Map(company, companys);
                await _NewCompanyRepository.UpdateAsync(companys);
            }
            return(input.Id);
        }
        public async Task <IActionResult> Create(CreateCompany model)
        {
            var requestUrl = client.CreateRequestUri(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Company"));
            var response   = await client.PostAsync(requestUrl, model);

            return(this.RedirectToAction(nameof(HomeController.Index), "Home"));
        }
Beispiel #7
0
        public int CreateCompany(CreateCompany dto)
        {
            Company company = mapper.Map <Company>(dto);

            companyRepository.CreateCompany(company);

            return(company.Id);
        }
        public void CreateCompany_Test()
        {
            var createComapny = new CreateCompany();

            companyRepoMock.Setup(x => x.CreateCompany(It.IsAny <Company>())).Verifiable();

            comapnyService.CreateCompany(createComapny);

            companyRepoMock.Verify(x => x.CreateCompany(It.IsAny <Company>()), Times.Once);
        }
Beispiel #9
0
        public async Task <IActionResult> CreateAsync([FromBody] CreateCompany request, CancellationToken cancellationToken)
        {
            var company = new Company(request.Name, request.ParentId);

            _companyRepository.Add(company);
            await _companyRepository.UnitOfWork.SaveChangesAsync(cancellationToken);

            var vm = _mapper.Map <ViewCompany>(company);

            return(CreatedAtAction(nameof(GetAsync), new { id = vm.Id }, vm));
        }
Beispiel #10
0
        public void Run()
        {

            IExecutable command = null;
            string line = Console.ReadLine();
            while (line != "end")
            {
                string[] tokens = line.Split();

                switch (tokens[0])
                {
                    case "create-company":
                        command = new CreateCompany(db, tokens[1], tokens[2], tokens[3], decimal.Parse(tokens[4]));
                        break;
                    case "create-employee":
                        string departmentName = null;
                        if (tokens.Length > 5)
                        {
                            departmentName = tokens[5];
                        }
                        command = new CreateEmployee(db, tokens[1], tokens[2], tokens[3], tokens[4], departmentName);
                        break;
                    case "create-department":
                        string mainDepartmentName = null;
                        if (tokens.Length > 5)
                        {
                            mainDepartmentName = tokens[5];
                        }
                        command = new CreateDepartment(db, tokens[1], tokens[2], tokens[3], tokens[4], mainDepartmentName);
                        break;
                    case "pay-salaries":
                        command = new PaySalaries(db, tokens[1]);
                        break;
                    case "show-employees":
                        command = new ShowEmployees(db, tokens[1]);
                        break;
                    default:
                        throw new ArgumentException("Unknoun command");
                }

                try
                {
                    Console.Write(command.Execute());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    line = Console.ReadLine();
                }
            }
        }
Beispiel #11
0
        public async Task <IActionResult> Post([FromBody] CreateCompany command)
        {
            if (!ModelState.IsValid)
            {
                return(await Task.FromResult(Ok(ModelState.Values.SelectMany(e => e.Errors).Select(e => e.ErrorMessage))));
            }
            var companyId = await _companyService.CreateAsync(command);

            await _companyService.AddEmployeesAsync(companyId, command.Employees);

            return(Created($"{companyId}", null));
        }
Beispiel #12
0
        public void UpdateComapny(CreateCompany updatedComapny, int Id)
        {
            Company company = companyRepository.GetComapnyByIdWithAddress(Id);

            if (company is null)
            {
                throw new NotFoundException($"There is no company with id: {Id}");
            }

            company = mapper.Map(updatedComapny, company);

            companyRepository.UpdateComapny(company);
        }
        public void UpdateCompany_Test()
        {
            var createComapny = new CreateCompany();
            var company       = getComapny();

            companyRepoMock.Setup(x => x.UpdateComapny(It.IsAny <Company>())).Verifiable();
            companyRepoMock.Setup(x => x.GetComapnyByIdWithAddress(company.Id))
            .Returns(company);

            comapnyService.UpdateComapny(createComapny, company.Id);

            companyRepoMock.Verify(x => x.UpdateComapny(It.IsAny <Company>()), Times.Once);
            Assert.Throws <NotFoundException>(() => comapnyService.UpdateComapny(createComapny, 2));
        }
Beispiel #14
0
        protected async Task <HttpResponseMessage> CreateCompanyImpl(string name, int?parentId)
        {
            var command = new CreateCompany
            {
                Name     = name,
                ParentId = parentId
            };

            var server         = await TestServers.OrganizationApiServer;
            var json           = JsonConvert.SerializeObject(command);
            var requestContent = new StringContent(json, Encoding.UTF8, ContentType.ApplicationJson);
            var client         = server.CreateClient();

            return(await client.PostAsync(Post.Companies, requestContent));
        }
Beispiel #15
0
        public IHttpActionResult Post([FromBody] CreateCompany company)
        {
            this.Log().Info("=> Post");

            var script = _powershellScriptLoader.LoadScript(PowershellScripts.CreateCompany);

            _powerShellManager
            .AddParameter("customerAccountId", company.CompanyOu)
            .AddParameter("baseHostingOu", _configurationManager.GetByKey("BaseHostingOu"))
            .AddParameter("targetDomainController", _configurationManager.GetByKey("TargetDomainController"));

            _powerShellManager.ExecuteScript(script);

            return(Ok());
        }
Beispiel #16
0
        public async Task <IActionResult> CreateCompany([FromBody] CreateCompany company)
        {
            var mapped = _mapper.Map <CreateCompanyDTO>(company);

            try
            {
                var companyId = await _companyService.CreateCompany(mapped);

                return(StatusCode(201, new { Id = companyId }));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500));
            }
        }
        [TestMethod()]//Checks if the method returns correct view if company is not created
        public void CreateComapnyController_CreateNewCompanyTestToCheckIfItReturnsCreateCompanyIndexViewWhenCompanyIsNotCreated()
        {
            CreateCompany createCompany = new CreateCompany();

            createCompany.AccountInfoID = accountInfo.ID;
            createCompany.AddressLine1  = "900 winslow way e";
            createCompany.AddressLine2  = "";
            createCompany.AddressLine3  = "";

            //Act

            var companyresult = createCompanyController.CreateNewCompany(createCompany) as ViewResult;


            //Assert
            Assert.AreEqual("Index", companyresult.ViewName);
        }
        public IApiResult Create(CreateCompany operation)
        {
            var result = operation.ExecuteAsync().Result;

            if (result is ValidationsOutput)
            {
                return(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                });
            }
            else
            {
                return(new ApiResult <object>()
                {
                    Status = ApiResult <object> .ApiStatus.Success
                });
            }
        }
Beispiel #19
0
        public virtual async Task <int> UpdateCompany(CreateCompanyOrContact input)
        {
            int TenantId = (int)(AbpSession.TenantId);
            var data     = _NewCompanyRepository.GetAll().Where(p => p.Name == input.Name && p.CustomerTypeId == input.CustomerTypeId && p.TenantId == TenantId && p.Id != input.Id).ToList();

            if (data.Count == 0)
            {
                CreateCompany company = new CreateCompany();
                company.Id               = input.Id;
                company.Name             = input.Name;
                company.CustomerTypeId   = input.CustomerTypeId;
                company.AccountManagerId = input.AccountManagerId;
                company.CountryId        = input.CountryId;
                company.CurrencyId       = input.CurrencyId;
                company.TenantId         = TenantId;
                var companys = await _NewCompanyRepository.GetAsync(input.Id);

                ObjectMapper.Map(company, companys);
                await _NewCompanyRepository.UpdateAsync(companys);
            }
            return(input.Id);
        }
Beispiel #20
0
        public virtual IHttpActionResult Post([FromBody] CreateCompany value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Company model;

            try
            {
                model = Company.Create(value);
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }

            repository.Insert(model);
            var dto = mapper.Map <GetCompany>(model);

            return(Created(nameof(Company) + "/" + dto.Id, dto));
        }
        [TestMethod()]//Checks if the method redirects to nexusSetup controller if company is created.
        public void CreateComapnyController_CreateNewCompanyTestToCheckIfItRedirectsToNexusSetupOnceCompanyIsCreated()
        {
            CreateCompany createCompany = new CreateCompany();

            createCompany.AccountInfoID = accountInfo.ID;
            createCompany.AddressLine1  = "900 winslow way e";
            createCompany.AddressLine2  = "";
            createCompany.AddressLine3  = "";
            createCompany.CompanyCode   = Guid.NewGuid().ToString().Substring(0, 8);
            createCompany.CompanyName   = "Systems of America1";
            createCompany.Country       = "US";
            createCompany.StateProvince = "WA";
            createCompany.TIN           = "95-3657472";

            createCompany.FirstName    = "abbott";
            createCompany.LastName     = "abbott";
            createCompany.PhoneNumber  = "9999999999";
            createCompany.Fax          = "9999999999";
            createCompany.Email        = "*****@*****.**";
            createCompany.City         = "Bainbridge Island";
            createCompany.ZipCode      = "98110";
            createCompany.MobileNumber = "";
            createCompany.Title        = "";
            createCompany.BIN          = "";


            //Act
            var companyresult = createCompanyController.CreateNewCompany(createCompany);


            //Assert

            RedirectToRouteResult routeResult = companyresult as RedirectToRouteResult;

            Assert.AreEqual(routeResult.RouteValues["action"], "Index", "Index Method of CreateCompany Controller failed to redirect to correct action!!");
            Assert.AreEqual(routeResult.RouteValues["controller"], "NexusSetup", "Index Method of CreateCompany Controller failed to redirect to correct controller!!");
        }
Beispiel #22
0
        public virtual async Task <int> CreateCompany(CreateCompanyOrContact input)
        {
            var id       = 0;
            var discount = _DiscountRepository.GetAll().FirstOrDefault();
            var data     = _NewCompanyRepository.GetAll().Where(p => p.Name == input.Name && p.NewCustomerTypeId == input.NewCustomerTypeId).ToList();

            if (data.Count == 0)
            {
                CreateCompany company = new CreateCompany()
                {
                    Name = input.Name,
                    NewCustomerTypeId = input.NewCustomerTypeId ?? null,
                    AccountManagerId  = input.AccountManagerId ?? null,
                    CustomerId        = input.CustomerId,
                    ApprovedById      = AbpSession.UserId,
                    IsApproved        = true,
                    TradeLicense      = input.TradeLicense,
                    TRNnumber         = input.TRNnumber,
                    IndustryId        = input.IndustryId ?? null,
                    Discountable      = discount != null ? (int)discount.Discountable : 0,
                    UnDiscountable    = discount != null ? (int)discount.UnDiscountable : 0,
                };
                var companys = company.MapTo <NewCompany>();
                id = _NewCompanyRepository.InsertAndGetId(companys);


                var comp = _NewCompanyRepository.GetAll().Where(p => p.Id == id).FirstOrDefault();

                comp.CustomerId = "FN-" + input.Name.Substring(0, 3).ToUpper() + id;
                await _NewCompanyRepository.UpdateAsync(comp);
            }
            else
            {
                id = data[0].Id;
            }
            return(id);
        }
Beispiel #23
0
        public virtual async Task <int> CreateCompany(CreateCompanyOrContact input)
        {
            int TenantId = (int)(AbpSession.TenantId);
            var id       = 0;
            var data     = _NewCompanyRepository.GetAll().Where(p => p.Name == input.Name && p.CustomerTypeId == input.CustomerTypeId && p.TenantId == TenantId).ToList();

            if (data.Count == 0)
            {
                CreateCompany company = new CreateCompany();
                company.Name             = input.Name;
                company.CustomerTypeId   = input.CustomerTypeId;
                company.AccountManagerId = input.AccountManagerId;
                company.CountryId        = input.CountryId;
                company.CurrencyId       = input.CurrencyId;
                company.TenantId         = TenantId;
                var companys = company.MapTo <Company>();
                id = _NewCompanyRepository.InsertAndGetId(companys);
            }
            else
            {
                id = data[0].Id;
            }
            return(id);
        }
Beispiel #24
0
        public static void Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Company")] HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed UpdateCompany.");
            //string company = req.Query["company"];

            string  requestBody = new StreamReader(req.Body).ReadToEnd();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);
            var     companyRead = (CompanyRead)data?.company;

            var createCompany = new CreateCompany
            {
                DataId                 = new Guid(),
                Address                = companyRead.Address,
                Name                   = companyRead.Name,
                CreationTime           = companyRead.CreationTime,
                CompanyId              = companyRead.CompanyId,
                CreateCompanyTimeStamp = DateTime.Now.Ticks
            };
            var createCompanyName = new CreateCompanyName
            {
                CompanyId = companyRead.CompanyId,
                Name      = companyRead.Name,
                CreateCompanyNameTimeStamp = DateTime.Now.Ticks
            };

            var createCompanyAddress = new CreateCompanyAddress
            {
                CompanyId = companyRead.CompanyId,
                Address   = companyRead.Address,
                CreateCompanyAddressTimeStamp = DateTime.Now.Ticks
            };

            _endpointInstance.Send(Helpers.ServerEndpoint, createCompany).ConfigureAwait(false);
            _endpointInstance.Send(Helpers.ServerEndpoint, createCompanyName).ConfigureAwait(false);
            _endpointInstance.Send(Helpers.ServerEndpoint, createCompanyAddress).ConfigureAwait(false);
        }
Beispiel #25
0
        private IEnumerable <string> ProcessCommands(ICollection <ICommand> commands)
        {
            var commandResults = new List <string>();

            foreach (var command in commands)
            {
                string commandResult;

                switch (command.Name)
                {
                case EngineConstants.CreateCompanyCommand:
                    var companyName = command.Parameters[0];
                    var companyRegistrationNumber = command.Parameters[1];
                    commandResult = CreateCompany.CreateCompanyMethod
                                        (companyName, companyRegistrationNumber,
                                        this.companyFactory, this.companies);
                    commandResults.Add(commandResult);
                    break;

                case EngineConstants.AddFurnitureToCompanyCommand:
                    var companyToAddTo     = command.Parameters[0];
                    var furnitureToBeAdded = command.Parameters[1];
                    commandResult = AddFurnitureToCompany.AddFurnitureToCompanyMethod(
                        companyToAddTo,
                        furnitureToBeAdded,
                        this.companies,
                        this.furnitures
                        );
                    commandResults.Add(commandResult);
                    break;

                case EngineConstants.RemoveFurnitureFromCompanyCommand:
                    var companyToRemoveFrom  = command.Parameters[0];
                    var furnitureToBeRemoved = command.Parameters[1];
                    commandResult = RemoveFurnitureFromCompany.RemoveFurnitureFromCompanyMethod(
                        companyToRemoveFrom,
                        furnitureToBeRemoved,
                        companies, furnitures);
                    commandResults.Add(commandResult);
                    break;

                case EngineConstants.FindFurnitureFromCompanyCommand:
                    var companyToFindFrom  = command.Parameters[0];
                    var furnitureToBeFound = command.Parameters[1];
                    commandResult = this.FindFurnitureFromCompany(companyToFindFrom, furnitureToBeFound);
                    commandResults.Add(commandResult);
                    break;

                case EngineConstants.ShowCompanyCatalogCommand:
                    var companyToShowCatalog = command.Parameters[0];
                    commandResult = this.ShowCompanyCatalog(companyToShowCatalog);
                    commandResults.Add(commandResult);
                    break;

                case EngineConstants.CreateTableCommand:
                    var tableModel    = command.Parameters[0];
                    var tableMaterial = command.Parameters[1];
                    var tablePrice    = decimal.Parse(command.Parameters[2]);
                    var tableHeight   = decimal.Parse(command.Parameters[3]);
                    var tableLength   = decimal.Parse(command.Parameters[4]);
                    var tableWidth    = decimal.Parse(command.Parameters[5]);
                    commandResult = this.CreateTable(tableModel, tableMaterial, tablePrice, tableHeight, tableLength, tableWidth);
                    commandResults.Add(commandResult);
                    break;

                case EngineConstants.CreateChairCommand:
                    var chairModel    = command.Parameters[0];
                    var chairMaterial = command.Parameters[1];
                    var chairPrice    = decimal.Parse(command.Parameters[2]);
                    var chairHeight   = decimal.Parse(command.Parameters[3]);
                    var chairLegs     = int.Parse(command.Parameters[4]);
                    commandResult = this.CreateChair(chairModel, chairMaterial, chairPrice, chairHeight, chairLegs);
                    commandResults.Add(commandResult);
                    break;

                default:
                    commandResults.Add(string.Format(EngineConstants.InvalidCommandErrorMessage, command.Name));
                    break;
                }
            }

            return(commandResults);
        }
Beispiel #26
0
        public async Task <long> CreateAsync(CreateCompany dto)
        {
            var company = new Company(dto.Name, (int)dto.EstablishmentYear);

            return(await _companyRepository.AddAsync(company));
        }
Beispiel #27
0
        public async Task <IActionResult> Create(CreateCompany company)
        {
            if (ModelState.IsValid)
            {
                var existCode = await _context.Company.Find(_ => _.CompanyCode == company.CompanyCode).FirstOrDefaultAsync();

                if (existCode == null)
                {
                    var currentUser = await _userManager.GetUserAsync(User);

                    company.OwnerId         = currentUser.Id;
                    company.CreatedBy       = currentUser.UserName;
                    company.Culture         = System.Globalization.CultureInfo.CurrentCulture.Name.Split('-')[0];
                    company.LanguageDefault = System.Globalization.CultureInfo.CurrentCulture.Name;;

                    var appDomain = Environment.GetEnvironmentVariable("APP_DOMAIN");

                    //await _context.Company.InsertOneAsync(company);
                    var result = await _createCompanyRequestClient.Request(company);

                    currentUser.Companies.Add(result.Id);
                    await _userManager.UpdateAsync(currentUser);

                    using (var scope = _scopeFactory.CreateScope())
                    {
                        var context = scope.ServiceProvider.GetRequiredService <IConfigurationDbContext>();

                        var client = new Client
                        {
                            ClientId                    = result.Id,
                            ClientName                  = $"{result.CompanyName} Application",
                            RequireConsent              = false,
                            AllowedGrantTypes           = GrantTypes.Implicit,
                            AllowAccessTokensViaBrowser = true,
                            RequireClientSecret         = false,
                            AccessTokenType             = AccessTokenType.Jwt,

                            RedirectUris =
                            {
                                //http
                                $"http://{result.CompanyCode}.{appDomain}",
                                $"http://{result.CompanyCode}.{appDomain}/callback.html",
                                $"http://{result.CompanyCode}.{appDomain}/silent.html",
                                $"http://{result.CompanyCode}.{appDomain}/popup.html",
                                //https
                                $"https://{result.CompanyCode}.{appDomain}",
                                $"https://{result.CompanyCode}.{appDomain}/callback.html",
                                $"https://{result.CompanyCode}.{appDomain}/silent.html",
                                $"https://{result.CompanyCode}.{appDomain}/popup.html"
                            },

                            PostLogoutRedirectUris =
                            {
                                $"http://{result.CompanyCode}.{appDomain}",
                                $"https://{result.CompanyCode}.{appDomain}"
                            },
                            AllowedCorsOrigins =
                            {
                                $"http://{result.CompanyCode}.{appDomain}",
                                $"https://{result.CompanyCode}.{appDomain}"
                            },
                            AllowedScopes =
                            {
                                IdentityServerConstants.StandardScopes.OpenId,
                                IdentityServerConstants.StandardScopes.Profile,
                                IdentityServerConstants.StandardScopes.Email,
                                "api",                                         "api2.read_only", "api2.full_access"
                            }
                        };
                        await context.AddClient(client.ToEntity());
                    }

                    return(RedirectToAction("UploadLogo", new { result.Id }));
                }
                else
                {
                    ModelState.AddModelError("CompanyCode", _localizer.GetLocalizedHtmlString("companyCodeExisted"));
                }
            }
            return(View(company));
        }
Beispiel #28
0
        public async Task <ActionResult <ApiResult> > Create(CreateCompany request)
        {
            request.UserUid = _currentUserProvider.GetUserUid();

            return(await _mediator.Send(request));
        }
        public async Task CreateCompany_Should_CreateCompany()
        {
            // arrange
            var cancellationToken = new CancellationToken();
            var unitOfWorkFactory = new TransactionScopeUnitOfWorkFactory();
            var dbContextFactory  = new DefaultDbContextFactory();
            var dateTimeProvider  = new DefaultDateTimeProvider();

            var mediatorMock = new Mock <IPublisher>();

            var fieldProviderRegistry = new DefaultFieldProviderRegistry();

            fieldProviderRegistry.AddFieldType(typeof(TextField));

            // var dbFieldMetadataRepository = new DbFieldMetadataRepository(dbContextFactory, fieldProviderRegistry, new NewtonsoftJsonSerializer());
            var dbFieldDataRepository       = new DbFieldDataRepository(dbContextFactory, fieldProviderRegistry);
            var classifierRepositoryFactory = CreateClassifierRepositoryFactory(dbContextFactory);
            var dbNumberGenerator           = new DbNumberGenerator(dbContextFactory, classifierRepositoryFactory, dateTimeProvider, Array.Empty <INumberTagResolver>());
            var dbDocumentService           = new DbDocumentService(dbContextFactory, dbNumberGenerator, mediatorMock.Object);
            var jsonSerializer        = new DefaultJsonSerializer();
            var auditLogService       = new DbAuditLogService(dbContextFactory, jsonSerializer);
            var classifierRegistrator = new DefaultClassifierRegistrator(NullLogger <DefaultClassifierRegistrator> .Instance, classifierRepositoryFactory);

            var metadataRepositoryMock = new Mock <IRepository <FieldMetadata> >();

            metadataRepositoryMock
            .Setup(x => x.Search(It.IsAny <MetadataSearchRequest>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => new SearchResult <FieldMetadata>
            {
                Rows = new FieldMetadata[]
                {
                    new TextField {
                        Key = "test1", Active = true, System = false
                    },
                    new TextField {
                        Key = "test2", Active = true, System = false
                    },
                    new TextField {
                        Key = "test3", Active = true, System = false
                    }
                }
            });

            var backgroundJobManagerMock = new Mock <IBackgroundJobManager>();

            var generator = new MasterDataDbGenerator(unitOfWorkFactory, dbContextFactory);

            var handler = new CreateCompanyHandler(unitOfWorkFactory,
                                                   dbContextFactory, dateTimeProvider, metadataRepositoryMock.Object,
                                                   dbFieldDataRepository, classifierRepositoryFactory, dbDocumentService, auditLogService, backgroundJobManagerMock.Object);

            using (var _ = unitOfWorkFactory.Create())
            {
                await generator.EnsureClassifierTypeRegistered(Numerator.GetDefaultMetadata(), cancellationToken);

                await generator.EnsureClassifierTypeRegistered(DocumentType.GetDefaultMetadata(), cancellationToken);

                foreach (var classifier in RegisterClassifiersStartupTask.GetClassifiers())
                {
                    await classifierRegistrator.Register(classifier, cancellationToken);
                }

                // act
                var company = new Company
                {
                    ConfigCode = "company",
                    Name       = "Montr Inc.",
                    Fields     = new FieldData
                    {
                        { "test1", "value1" },
                        { "test2", "value2" },
                        { "test3", "value3" }
                    }
                };

                var command = new CreateCompany
                {
                    UserUid = Guid.NewGuid(),
                    Item    = company
                };

                var result = await handler.Handle(command, cancellationToken);

                // assert
                Assert.IsNotNull(result);
                Assert.IsTrue(result.Success);
                Assert.IsNotNull(result.Uid);
                Assert.AreNotEqual(Guid.Empty, result.Uid);

                // assert registration request inserted
                DbDocument dbDocument;
                using (var db = dbContextFactory.Create())
                {
                    dbDocument = await db.GetTable <DbDocument>()
                                 .Where(x => x.CompanyUid == result.Uid)
                                 .SingleAsync(cancellationToken);
                }

                Assert.IsNotNull(dbDocument);

                // assert registration request field data inserted
                IList <DbFieldData> fieldData;
                using (var db = dbContextFactory.Create())
                {
                    fieldData = await db.GetTable <DbFieldData>()
                                .Where(x => x.EntityTypeCode == Document.TypeCode && x.EntityUid == dbDocument.Uid)
                                .ToListAsync(cancellationToken);
                }

                Assert.AreEqual(company.Fields.Count, fieldData.Count);
                Assert.AreEqual(company.Fields["test1"], fieldData.Single(x => x.Key == "test1").Value);
                Assert.AreEqual(company.Fields["test2"], fieldData.Single(x => x.Key == "test2").Value);
                Assert.AreEqual(company.Fields["test3"], fieldData.Single(x => x.Key == "test3").Value);
            }
        }
Beispiel #30
0
        private void Btn_CreateCompany_Click(object sender, EventArgs e)
        {
            CreateCompany company = new CreateCompany();

            company.Show();
        }
Beispiel #31
0
 public async Task Post([FromBody] CreateCompany company)
 {
     await _companyService.AddAsync(_mapper.Map <CreateCompany, CompanyDTO>(company));
 }