Beispiel #1
0
        public async Task <ActionResult <CompanyViewModel> > GetCompany(int CompanyId)
        {
            CompanyDTO company = await companyServ.GetCompany(CompanyId);

            CountryDTO country = await countryServ.GetCountry(company.HGBasedInCountryId);

            CompanyQualification companyQualification = qualificationServ.GetQualifications().Result.Where(p => p.Id == company.QualificationId).FirstOrDefault();
            string userName = "";

            if (company.LeadOwnerId != null)
            {
                userName = await userRegistrationServ.GetUserFullName(company.LeadOwnerId);
            }
            string region = await regionServ.GetRegionName(country.RegionId);

            CompanyViewModel companyView = new CompanyViewModel
            {
                CompanyLegalName     = company.CompanyLegalName,
                CompanyRegion        = region,
                HGBasedInCountryName = country.Name,
                Id = company.Id,
                LeadOwnerFullName = userName,
                QualificationName = companyQualification.QualificationName,
                QualifiedDate     = company.QualifiedDate,
                TradingName       = company.TradingName,
                Website           = company.Website
            };

            return(Ok(companyView));
        }
Beispiel #2
0
        public async Task UpdateCompanies()
        {
            List <CompanyModel> companies = new List <CompanyModel>();
            await Task.Run(async() =>
            {
                foreach (var company in await companyServ.GetCompanies())
                {
                    var Qualifications    = await qualificationServ.GetQualifications();
                    var QualificationName = Qualifications.Where(p => p.Id == company.QualificationId).FirstOrDefault().QualificationName;
                    var lead    = await userRegistrationServ.GetUserFullName(company.LeadOwnerId);
                    var country = await countryServ.GetCountry(company.HGBasedInCountryId);
                    CompanyModel companyModel = new CompanyModel
                    {
                        CompanyLegalName     = company.CompanyLegalName,
                        HGBasedInCountryName = country.Name,
                        Id = company.Id,
                        LeadOwnerFullName = lead,
                        QualificationName = QualificationName,
                        QualifiedDate     = company.QualifiedDate,
                        TradingName       = company.TradingName,
                        Website           = company.Website
                    };
                    companies.Add(companyModel);
                }
            }
                           );

            companyModels = companies;

            /*IEnumerable<CompanyDTO> companies = await companyServ.GetCompanies();
             * var mapper = new MapperConfiguration(cfg => cfg.CreateMap<CompanyDTO, CompanyModel>()
             * .ForMember(p=>p.HGBasedInCountryName, p=>p.MapFrom(s=>countryServ.GetCountry(s.HGBasedInCountryId).Result.Name))
             * .ForMember(p => p.LeadOwnerFullName, p => p.MapFrom(s =>  userRegistrationServ.GetUserFullName(s.LeadOwnerId)))
             * .ForMember(p => p.QualificationName, p => p.MapFrom(s => qualificationServ.GetQualifications().Result.Where(p=>p.Id==s.QualificationId).FirstOrDefault().QualificationName))
             * ).CreateMapper();
             * companyModels  = mapper.Map<IEnumerable<CompanyDTO>, IEnumerable<CompanyModel>>(companies);*/
        }
        public async Task UpdateCompanies()
        {
            AllCompanies = await companyServ.GetCompanies();

            NewCompanies = await companyServ.GetNewCompanies();

            QualifiedCompanies = await companyServ.GetQualifiedCompanies();

            NotQualifiedCompanies = await companyServ.GetNotQualifiedCompanies();

            Linkedins = await db.Linkedins.ToListAsync();

            CompanyContactLinks = await mailFindServ.GetCompanyContactLinks();

            Countries = await countryServ.GetCountries();

            Contacts = await mailFindServ.GetAllContacts();

            List <CompanyModel> companies = new List <CompanyModel>();
            await Task.Run(async() =>
            {
                foreach (var company in await companyServ.GetCompanies())
                {
                    var Qualifications    = await db.CompanyQualifications.ToListAsync();
                    var QualificationName = Qualifications.Where(p => p.Id == company.QualificationId).FirstOrDefault().QualificationName;
                    var lead    = await userRegistrationServ.GetUserFullName(company.LeadOwnerId);
                    var country = await countryServ.GetCountry(company.HGBasedInCountryId);

                    string linkedinLink = null;
                    if (company.CompanyLinkedinId != 0)
                    {
                        var linkedin = await db.Linkedins.FindAsync(company.CompanyLinkedinId);
                        linkedinLink = linkedin.FullLink;
                    }
                    CompanyModel companyModel = new CompanyModel
                    {
                        CompanyLegalName     = company.CompanyLegalName,
                        HGBasedInCountryName = country.Name,
                        Id = company.Id,
                        LeadOwnerFullName       = lead,
                        QualificationName       = QualificationName,
                        QualifiedDate           = company.QualifiedDate,
                        TradingName             = company.TradingName,
                        Website                 = company.Website,
                        CompanyLinkedinFullLink = linkedinLink
                    };
                    companies.Add(companyModel);
                }
            }
                           );

            CompanyModels = companies;
            await UpdateLogs();

            /*IEnumerable<CompanyDTO> companies = await companyServ.GetCompanies();
             * var mapper = new MapperConfiguration(cfg => cfg.CreateMap<CompanyDTO, CompanyModel>()
             * .ForMember(p=>p.HGBasedInCountryName, p=>p.MapFrom(s=>countryServ.GetCountry(s.HGBasedInCountryId).Result.Name))
             * .ForMember(p => p.LeadOwnerFullName, p => p.MapFrom(s =>  userRegistrationServ.GetUserFullName(s.LeadOwnerId)))
             * .ForMember(p => p.QualificationName, p => p.MapFrom(s => qualificationServ.GetQualifications().Result.Where(p=>p.Id==s.QualificationId).FirstOrDefault().QualificationName))
             * ).CreateMapper();
             * companyModels  = mapper.Map<IEnumerable<CompanyDTO>, IEnumerable<CompanyModel>>(companies);*/
        }