public async Task <Payment> UpdatePaymentAsync(Payment payment)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var paymentDb = await db.Payments.Where(x => x.Id == payment.Id).FirstOrDefaultAsync();

                var totalDays = (DateTime.UtcNow - paymentDb.PaymentOn.Value).TotalDays;

                if (totalDays > paymentDb.Validity)
                {
                    paymentDb.Validity = payment.Validity;
                }
                else if (totalDays == paymentDb.Validity)
                {
                    paymentDb.Validity = payment.Validity + 1;
                }
                else if (totalDays < paymentDb.Validity)
                {
                    paymentDb.Validity = paymentDb.Validity - (int)totalDays + payment.Validity + 1;
                }

                paymentDb.Guide     = Guid.NewGuid();
                paymentDb.PaymentOn = DateTime.UtcNow;
                paymentDb.UpdateOn  = DateTime.UtcNow;

                await db.SaveChangesAsync();

                return(paymentDb);
            }
        }
        public async Task InsertSuitableProfilesAsync(IEnumerable <SuitableProfile> suitableProfiles)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                foreach (var suitableProfile in suitableProfiles)
                {
                    suitableProfile.FirstName        = string.IsNullOrEmpty(suitableProfile.FirstName) ? "..." : suitableProfile.FirstName;
                    suitableProfile.LastName         = string.IsNullOrEmpty(suitableProfile.LastName) ? "..." : suitableProfile.LastName;
                    suitableProfile.Job              = string.IsNullOrEmpty(suitableProfile.Job) ? "..." : suitableProfile.Job;
                    suitableProfile.PersonLinkedIn   = string.IsNullOrEmpty(suitableProfile.PersonLinkedIn) ? "..." : suitableProfile.PersonLinkedIn;
                    suitableProfile.Company          = string.IsNullOrEmpty(suitableProfile.Company) ? "..." : suitableProfile.Company;
                    suitableProfile.Website          = string.IsNullOrEmpty(suitableProfile.Website) ? "..." : suitableProfile.Website;
                    suitableProfile.CompanyLogoUrl   = string.IsNullOrEmpty(suitableProfile.CompanyLogoUrl) ? "..." : suitableProfile.CompanyLogoUrl;
                    suitableProfile.CrunchUrl        = string.IsNullOrEmpty(suitableProfile.CrunchUrl) ? "..." : suitableProfile.CrunchUrl;
                    suitableProfile.Email            = string.IsNullOrEmpty(suitableProfile.Email) ? "..." : suitableProfile.Email;
                    suitableProfile.EmailStatus      = string.IsNullOrEmpty(suitableProfile.EmailStatus) ? "..." : suitableProfile.EmailStatus;
                    suitableProfile.City             = string.IsNullOrEmpty(suitableProfile.City) ? "..." : suitableProfile.City;
                    suitableProfile.State            = string.IsNullOrEmpty(suitableProfile.State) ? "..." : suitableProfile.State;
                    suitableProfile.Country          = string.IsNullOrEmpty(suitableProfile.Country) ? "..." : suitableProfile.Country;
                    suitableProfile.PhoneNumber      = string.IsNullOrEmpty(suitableProfile.PhoneNumber) ? "..." : suitableProfile.PhoneNumber;
                    suitableProfile.AmountEmployees  = string.IsNullOrEmpty(suitableProfile.AmountEmployees) ? "..." : suitableProfile.AmountEmployees;
                    suitableProfile.Industry         = string.IsNullOrEmpty(suitableProfile.Industry) ? "..." : suitableProfile.Industry;
                    suitableProfile.Twitter          = string.IsNullOrEmpty(suitableProfile.Twitter) ? "..." : suitableProfile.Twitter;
                    suitableProfile.Facebook         = string.IsNullOrEmpty(suitableProfile.Facebook) ? "..." : suitableProfile.Facebook;
                    suitableProfile.TechStack        = string.IsNullOrEmpty(suitableProfile.TechStack) ? "..." : suitableProfile.TechStack;
                    suitableProfile.DateTimeCreation = DateTime.Now;

                    db.SuitableProfiles.Add(suitableProfile);
                }

                await db.SaveChangesAsync();
            }
        }
 public async Task InsertSettingAsync(Setting setting)
 {
     using (var db = new ScraperLinkedInDBEntities())
     {
         db.Settings.Add(setting);
         await db.SaveChangesAsync();
     }
 }
Exemple #4
0
 public async Task InsertCompanyAsync(Company company)
 {
     using (var db = new ScraperLinkedInDBEntities())
     {
         db.Companies.Add(company);
         await db.SaveChangesAsync();
     }
 }
Exemple #5
0
 public async Task InsertDebugLogAsync(DebugLog debugLog)
 {
     using (var db = new ScraperLinkedInDBEntities())
     {
         db.DebugLogs.Add(debugLog);
         await db.SaveChangesAsync();
     }
 }
 public async Task DeleteAccountAsync(int accountId)
 {
     using (var db = new ScraperLinkedInDBEntities())
     {
         var accountDb = db.Accounts.Where(x => x.Id == accountId).FirstOrDefault();
         accountDb.IsDeleted = true;
         await db.SaveChangesAsync();
     }
 }
 public async Task ChangeAccountBlockAsync(int accountId, bool isBlocked)
 {
     using (var db = new ScraperLinkedInDBEntities())
     {
         var accountDb = db.Accounts.Where(x => x.Id == accountId).FirstOrDefault();
         accountDb.IsBlocked = isBlocked;
         await db.SaveChangesAsync();
     }
 }
 public async Task ChangeAccountRoleAsync(int accountId, string role)
 {
     using (var db = new ScraperLinkedInDBEntities())
     {
         var accountDb = db.Accounts.Where(x => x.Id == accountId).FirstOrDefault();
         accountDb.Role = role;
         await db.SaveChangesAsync();
     }
 }
        public async Task <Account> InsertAccountAsync(Account account)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var accountDb = db.Accounts.Add(account);
                await db.SaveChangesAsync();

                return(accountDb);
            }
        }
        public async Task UpdateScraperStatus(int accountId, Models.Types.ScraperStatus status)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var settings = await db.Settings.Where(x => x.AccountId == accountId).FirstOrDefaultAsync();

                settings.ScraperStatusID = (int)status;

                await db.SaveChangesAsync();
            }
        }
Exemple #11
0
        public async Task InsertDebugLogsAsync(IEnumerable <DebugLog> debugLogs)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                foreach (var debugLog in debugLogs)
                {
                    db.DebugLogs.Add(debugLog);
                }

                await db.SaveChangesAsync();
            }
        }
Exemple #12
0
        public async Task UpdateCompanyAsync(Company company)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var companyDB = await db.Companies.Where(x => x.Id == company.Id).FirstOrDefaultAsync();

                companyDB.LogoUrl           = company.LogoUrl ?? "";
                companyDB.Specialties       = company.Specialties ?? "";
                companyDB.ExecutionStatusID = company.ExecutionStatusID;

                await db.SaveChangesAsync();
            }
        }
Exemple #13
0
        public async Task <IEnumerable <Company> > GetCompaniesForSearchAsync(int accountId, int companyBatchSize)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var companiesDb = db.Companies.Where(x => x.AccountId == accountId && !string.IsNullOrEmpty(x.LinkedInURL.Trim()) && (x.ExecutionStatusID == (int)Models.Types.ExecutionStatus.Created || x.ExecutionStatusID == (int)Models.Types.ExecutionStatus.Queued))
                                  .Take(companyBatchSize);

                Enumerable.ToList(companiesDb).ForEach(x => x.ExecutionStatusID = (int)Models.Types.ExecutionStatus.Queued);
                await db.SaveChangesAsync();

                return(await companiesDb.ToListAsync());
            }
        }
        public async Task UpdateProfilesExecutionStatusByCompanyIdAsync(int accountId, int companyId, Models.Types.ExecutionStatus executionStatus)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var profiles = db.Profiles.Where(x => x.AccountID == accountId && x.CompanyID == companyId);
                foreach (var profile in profiles)
                {
                    profile.ExecutionStatusID = (int)executionStatus;
                }

                await db.SaveChangesAsync();
            }
        }
Exemple #15
0
        public async Task UpdateLastPageCompanyAsync(int accountId, int companyId, int lastScrapedPage)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var companyDB = await db.Companies.Where(x => x.AccountId == accountId && x.Id == companyId).FirstOrDefaultAsync();

                if (companyDB != null)
                {
                    companyDB.LastScrapedPage = lastScrapedPage;

                    await db.SaveChangesAsync();
                }
            }
        }
        public async Task <Payment> UpdatePaymentGuideAsync(int id, int accountId, Guid guid)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var paymentDb = await db.Payments.Where(x => x.Id == id && x.AccountId == accountId).FirstOrDefaultAsync();

                paymentDb.Guide    = guid;
                paymentDb.UpdateOn = DateTime.UtcNow;

                await db.SaveChangesAsync();

                return(paymentDb);
            }
        }
Exemple #17
0
        public async Task UpdateAdvanceSettingAsync(AdvanceSetting advanceSetting)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var advanceSettingsDb = await db.AdvanceSettings.Where(x => x.Id == advanceSetting.Id).FirstOrDefaultAsync();

                advanceSettingsDb.TimeStart        = advanceSetting.TimeStart;
                advanceSettingsDb.IntervalType     = advanceSetting.IntervalType;
                advanceSettingsDb.IntervalValue    = advanceSetting.IntervalValue;
                advanceSettingsDb.CompanyBatchSize = advanceSetting.CompanyBatchSize;
                advanceSettingsDb.ProfileBatchSize = advanceSetting.ProfileBatchSize;

                await db.SaveChangesAsync();
            }
        }
        public async Task UpdateSettingAsync(Setting setting)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var settingDB = await db.Settings.Where(x => x.AccountId == setting.AccountId).FirstOrDefaultAsync();

                settingDB.Token              = setting.Token;
                settingDB.Login              = setting.Login;
                settingDB.Password           = setting.Password;
                settingDB.TechnologiesSearch = setting.TechnologiesSearch;
                settingDB.RolesSearch        = setting.RolesSearch;

                await db.SaveChangesAsync();
            }
        }
        public async Task UpdateAccountAsync(Account account)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var accountDb = db.Accounts.Where(x => x.Id == account.Id).FirstOrDefault();

                accountDb.FirstName      = account.FirstName;
                accountDb.LastName       = account.LastName;
                accountDb.Email          = account.Email;
                accountDb.Phone          = account.Phone;
                accountDb.DateOfBirthday = account.DateOfBirthday;

                await db.SaveChangesAsync();
            }
        }
        public async Task <Payment> InsertPaymentAsync(Payment payment)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                payment.Guide     = Guid.NewGuid();
                payment.CreateOn  = DateTime.UtcNow;
                payment.PaymentOn = DateTime.UtcNow;
                payment.UpdateOn  = DateTime.UtcNow;

                var paymentDb = db.Payments.Add(payment);
                await db.SaveChangesAsync();

                return(paymentDb);
            }
        }
        public async Task <IEnumerable <Profile> > GetProfilesForSearchAsync(int accountId, int profilesBatchSize)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var result = db.Profiles.Where(x => x.AccountID == accountId && ((x.ProfileStatusID == (int)Models.Types.ProfileStatus.Undefined) && (x.ExecutionStatusID == (int)Models.Types.ExecutionStatus.Created || x.ExecutionStatusID == (int)Models.Types.ExecutionStatus.Queued)))
                             .Take(profilesBatchSize).Include(x => x.Company);

                result.Where(x => x.ExecutionStatusID == (int)Models.Types.ExecutionStatus.Created)
                .ToList()
                .ForEach(x => x.ExecutionStatusID = (int)Models.Types.ExecutionStatus.Queued);

                await db.SaveChangesAsync();

                return(await result.ToListAsync());
            }
        }
        public async Task InsertProfilesAsync(IEnumerable <Profile> profiles)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var companyID   = profiles.FirstOrDefault().CompanyID;
                var addProfiles = db.Profiles.Where(x => x.CompanyID == companyID && x.ExecutionStatusID != (int)Models.Types.ExecutionStatus.Success)
                                  .Select(x => x.ProfileUrl);

                foreach (var profile in profiles.Where(x => !addProfiles.Contains(x.ProfileUrl)))
                {
                    profile.DateСreation = DateTime.Now;
                    db.Profiles.Add(profile);
                }

                await db.SaveChangesAsync();
            }
        }
Exemple #23
0
        public async Task InsertCompaniesAsync(IEnumerable <Company> companies)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                var addedCompaniesUrl = await db.Companies.Where(x => x.LinkedInURL != null && x.LinkedInURL.Trim() != "" && x.ExecutionStatusID != (int)Models.Types.ExecutionStatus.Success)
                                        .Select(x => x.LinkedInURL).ToListAsync();

                companies = companies.Where(x => !addedCompaniesUrl.Contains(x.LinkedInURL));

                foreach (var company in companies)
                {
                    company.Founders = company.Founders ?? "";
                    company.Website  = company.Website ?? "";

                    db.Companies.Add(company);
                }

                db.SaveChanges();
                await db.SaveChangesAsync();
            }
        }
        public async Task UpdateProfilesAsync(IEnumerable <Profile> profiles)
        {
            using (var db = new ScraperLinkedInDBEntities())
            {
                foreach (var profile in profiles)
                {
                    var profileDB = db.Profiles.Where(x => x.Id == profile.Id).FirstOrDefault();

                    profileDB.FirstName         = profile.FirstName ?? "";
                    profileDB.LastName          = profile.LastName ?? "";
                    profileDB.FullName          = profile.FullName ?? "";
                    profileDB.Job               = profile.Job ?? "";
                    profileDB.AllSkills         = profile.AllSkills ?? "";
                    profileDB.ExecutionStatusID = profile.ExecutionStatusID;
                    profileDB.ProfileStatusID   = profile.ProfileStatusID;
                    profileDB.DateСreation      = profile.DateСreation;
                }

                await db.SaveChangesAsync();
            }
        }