public async Task <CompanyRegistrationDTO> CreateCompany(CompanyRegistrationDTO CompanyRegistrationDTO)
        {
            CompanyQualification NewCompany = await db.CompanyQualifications.Where(p => p.QualificationName == "NewCompany").FirstOrDefaultAsync();

            var country = await countryServ.GetCountry(CompanyRegistrationDTO.HGBasedInCountryId);

            if (country == null)
            {
                throw new Exception("Id Страны не правильная");
            }
            Company company;

            if (CompanyRegistrationDTO.CompanyLinkedinLink != null)
            {
                Linkedin linkedin = new Linkedin {
                    FullLink = CompanyRegistrationDTO.CompanyLinkedinLink
                };
                await db.Linkedins.AddAsync(linkedin);

                company = new Company
                {
                    CompanyLegalName   = CompanyRegistrationDTO.CompanyLegalName,
                    HGBasedInCountryId = CompanyRegistrationDTO.HGBasedInCountryId,
                    Qualification      = NewCompany,
                    TradingName        = CompanyRegistrationDTO.TradingName,
                    Website            = CompanyRegistrationDTO.Website,
                    CompanyLinkedin    = linkedin
                };
            }
            else
            {
                company = new Company
                {
                    CompanyLegalName   = CompanyRegistrationDTO.CompanyLegalName,
                    HGBasedInCountryId = CompanyRegistrationDTO.HGBasedInCountryId,
                    Qualification      = NewCompany,
                    TradingName        = CompanyRegistrationDTO.TradingName,
                    Website            = CompanyRegistrationDTO.Website
                };
            }
            await db.Companies.AddAsync(company);

            await db.SaveChangesAsync();

            return(CompanyRegistrationDTO);
        }
Example #2
0
        /// controls END
        #endregion
        #region BASE_METHODS
        protected override async Task OnInitializedAsync()
        {
            NewCompany          = new CompanyRegistrationDTO();
            AddLemlistStatistic = new AddLemlistStatistic();
            checkedContacts     = new List <int>();
            await TempService.UpdateCompanies();

            await RenderUpdate();

            authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            user = authState.User;
            if (user.Identity.IsAuthenticated)
            {
                TempService.CurrentUser = await UserRegistrationService.GetCurrent(user.Identity.Name);
            }
            await StartCountdown();
        }
Example #3
0
        public async Task <CompanyRegistrationDTO> EditCompany(CompanyRegistrationDTO CompanyDTO)
        {
            Company company = await db.Companies.FindAsync(CompanyDTO.Id);

            company.CompanyLegalName = CompanyDTO.CompanyLegalName;
            var country = countryServ.GetCountry(CompanyDTO.HGBasedInCountryId);

            if (country == null)
            {
                throw new Exception("Id Страны не правильная");
            }
            company.HGBasedInCountryId = CompanyDTO.HGBasedInCountryId;
            company.TradingName        = CompanyDTO.TradingName;
            company.Website            = CompanyDTO.Website;
            db.Companies.Update(company);
            await db.SaveChangesAsync();

            return(CompanyDTO);
        }
Example #4
0
        public async Task <CompanyRegistrationDTO> CreateCompany(CompanyRegistrationDTO CompanyRegistrationDTO)
        {
            CompanyQualification NewCompany = qualificationServ.GetQualifications().Result.Where(p => p.QualificationName == "NewCompany").FirstOrDefault();
            var country = countryServ.GetCountry(CompanyRegistrationDTO.HGBasedInCountryId);

            if (country == null)
            {
                throw new Exception("Id Страны не правильная");
            }
            Company company = new Company
            {
                CompanyLegalName   = CompanyRegistrationDTO.CompanyLegalName,
                HGBasedInCountryId = CompanyRegistrationDTO.HGBasedInCountryId,
                Qualification      = NewCompany,
                TradingName        = CompanyRegistrationDTO.TradingName,
                Website            = CompanyRegistrationDTO.Website
            };
            await db.Companies.AddAsync(company);

            await db.SaveChangesAsync();

            return(CompanyRegistrationDTO);
        }
Example #5
0
        public async Task ImportCSV()
        {
            List <CompanyCsvModel> Companies;

            using (StreamReader streamReader = new StreamReader(CSV_PATH))
            {
                using (CsvReader csvReader = new CsvReader(streamReader, CultureInfo.InvariantCulture))
                {
                    // указываем используемый разделитель
                    csvReader.Configuration.Delimiter         = ",";
                    csvReader.Configuration.HeaderValidated   = null;
                    csvReader.Configuration.MissingFieldFound = null;
                    // получаем строки
                    Companies = csvReader.GetRecords <CompanyCsvModel>().ToList();
                }
            }
            foreach (var company in Companies ?? Enumerable.Empty <CompanyCsvModel>())
            {
                List <Region> regions = await db.Regions.Where(p => p.Name == company.RegionName).ToListAsync();

                Region region;
                if (regions.Count == 0)
                {
                    region = new Region {
                        Name = company.RegionName
                    };
                    await db.Regions.AddAsync(region);

                    await db.SaveChangesAsync();
                }
                else
                {
                    region = regions.First();
                }
                Country country = await db.Countries.Where(p => p.RegionId == region.Id && p.Name == company.HGBasedInCountry).FirstOrDefaultAsync();

                if (country == null)
                {
                    country = new Country {
                        Name = company.HGBasedInCountry, RegionId = region.Id
                    };
                    await db.Countries.AddAsync(country);

                    await db.SaveChangesAsync();
                }

                CompanyRegistrationDTO newCompany = new CompanyRegistrationDTO
                {
                    CompanyLegalName    = company.CompanyLegalName,
                    TradingName         = company.TradingName,
                    Website             = company.Website,
                    CompanyLinkedinLink = company.CompanyLinkedinLink,
                    HGBasedInCountryId  = country.Id
                };
                try
                {
                    await _companyService.CreateCompany(newCompany);
                }
                catch (Exception ex)
                {
                }
            }
        }
Example #6
0
        public async Task <ActionResult> EditCompany(CompanyRegistrationDTO CompanyRegistrationDTO)
        {
            await companyServ.EditCompany(CompanyRegistrationDTO);

            return(Ok(CompanyRegistrationDTO));
        }
Example #7
0
        public async Task <ActionResult <CompanyRegistrationDTO> > CreateCompany(CompanyRegistrationDTO CompanyRegistrationDTO)
        {
            await companyServ.CreateCompany(CompanyRegistrationDTO);

            return(Ok(CompanyRegistrationDTO));
        }