Пример #1
0
        internal static async Task <int> InsertCandidateSkills(List <int> Skills, tblCandidate can)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    foreach (int i in Skills)
                    {
                        var ind = db.tblCandidateSkills.Add(
                            new tblCandidateSkill
                        {
                            CandidateID      = can.ID,
                            SkillsID         = i,
                            IsActive         = true,
                            IsDeleted        = false,
                            CreatedTimestamp = can.CreatedTimestamp,
                            CreatedUserID    = can.CreatedUserID,
                            UpdatedTimestamp = can.UpdatedTimestamp,
                            UpdatedUserID    = can.UpdatedUserID
                        });
                    }

                    return(await Task.Run(() => db.SaveChangesAsync()));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        internal static async Task UpdateCandidateFiles(List <FileModel> model, tblCandidate Candidate)
        {
            try
            {
                int     x  = 0;
                tblFile fi = null;
                using (db = new eMSPEntities())
                {
                    await db.tblCandidateFiles.Where(a => a.CandidateID == Candidate.ID).ForEachAsync(a => { a.IsActive = false; a.IsDeleted = true; });


                    await Task.Run(() => db.SaveChangesAsync());

                    foreach (FileModel a in model)
                    {
                        fi = await Task.Run(() => InsertFiles(a.ConvertTotblFile()));

                        x = await Task.Run(() => InsertCandidateFiles(Candidate, fi, Convert.ToInt64(a.FileTypeId)));
                    }


                    //return model;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        internal static async Task <tblVacancyLocation> AddVacancyLocation(long a, tblVacancy vacancy)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblVacancyLocation model = new tblVacancyLocation();
                    model = db.tblVacancyLocations.Add(new tblVacancyLocation
                    {
                        VacancyID        = vacancy.ID,
                        LocationID       = a,
                        IsActive         = true,
                        IsDeleted        = false,
                        CreatedTimestamp = vacancy.CreatedTimestamp,
                        CreatedUserID    = vacancy.CreatedUserID,
                        UpdatedTimestamp = vacancy.UpdatedTimestamp,
                        UpdatedUserID    = vacancy.UpdatedUserID
                    });

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #4
0
        private static async Task UpdateContacts(List <CandidateContactModel> candidateContact, tblCandidate Candidate)
        {
            int        x       = 0;
            tblContact contact = null;

            using (db = new eMSPEntities())
            {
                await db.tblCandidateContacts.Where(a => a.CandidateID == Candidate.ID).ForEachAsync(a => { a.IsActive = false; a.IsDeleted = true; });


                await Task.Run(() => db.SaveChangesAsync());


                if (candidateContact.Count > 0)
                {
                    foreach (CandidateContactModel c in candidateContact)
                    {
                        contact = await Task.Run(() => InsertContacts(c.ConvertTotblContact()));

                        x = await Task.Run(() => InsertCandidateContacts(Candidate, contact, c.IsPrimary));
                    }
                }
                //return model;
            }
        }
Пример #5
0
 internal static async Task <int> InsertCandidateFiles(tblCandidate can, tblFile file, long fileTypeid, DateTime?exdate = null)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             var scandidate = db.tblCandidateFiles.Add(new tblCandidateFile
             {
                 FileID           = file.ID,
                 FileTypeID       = fileTypeid,
                 CandidateID      = can.ID,
                 IsActive         = true,
                 IsDeleted        = false,
                 ExpiryDate       = exdate,
                 CreatedTimestamp = can.CreatedTimestamp,
                 CreatedUserID    = can.CreatedUserID,
                 UpdatedTimestamp = can.UpdatedTimestamp,
                 UpdatedUserID    = can.UpdatedUserID
             });
             return(await Task.Run(() => db.SaveChangesAsync()));
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #6
0
        internal static async Task <tblUserProfile> InsertUser(tblUserProfile model, string companyType, long Id)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    model = db.tblUserProfiles.Add(model);

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    switch (companyType)
                    {
                    case "MSP":
                        db.tblMSPUsers.Add(ToCompanyUsers(model, companyType, Id));
                        break;

                    case "Customer":
                        db.tblCustomerUsers.Add(ToCompanyUsers(model, companyType, Id));
                        break;

                    case "Supplier":
                        db.tblSupplierUsers.Add(ToCompanyUsers(model, companyType, Id));
                        break;
                    }
                    x = await Task.Run(() => db.SaveChangesAsync());

                    return(GetUser(model.UserID).Result);
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Пример #7
0
        internal static async Task <tblVacancyLocation> UpdateVacancyLocation(long a, tblVacancy vacancy)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblVacancyLocation model = await Task.Run(() => db.tblVacancyLocations.Where(b => b.VacancyID == vacancy.ID && b.LocationID == a).FirstOrDefaultAsync());

                    if (model != null)
                    {
                        db.Entry(model).State = EntityState.Modified;

                        int x = await Task.Run(() => db.SaveChangesAsync());
                    }
                    else
                    {
                        model = await Task.Run(() => AddVacancyLocation(a, vacancy));
                    }

                    return(model);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #8
0
        internal static async Task <tblVacancyFile> InsertVacancyFiles(tblVacancyFile model, tblVacancy vacancy)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    model = db.tblVacancyFiles.Add(new tblVacancyFile
                    {
                        VacancyID        = vacancy.ID,
                        FilePath         = model.FilePath,
                        FileName         = model.FileName,
                        IsActive         = true,
                        IsDeleted        = false,
                        CreatedTimestamp = vacancy.CreatedTimestamp,
                        CreatedUserID    = vacancy.CreatedUserID,
                        UpdatedTimestamp = vacancy.UpdatedTimestamp,
                        UpdatedUserID    = vacancy.UpdatedUserID
                    });

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #9
0
        internal static async Task <tblVacancySupplier> InsertVacancySupplier(string a, tblVacancy vacancy)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblVacancySupplier model = new tblVacancySupplier();
                    model = db.tblVacancySuppliers.Add(new tblVacancySupplier
                    {
                        VacancyID        = vacancy.ID,
                        SupplierID       = Convert.ToInt16(a),
                        IsReleased       = true,
                        IsActive         = true,
                        IsDeleted        = false,
                        CreatedTimestamp = vacancy.CreatedTimestamp,
                        CreatedUserID    = vacancy.CreatedUserID,
                        UpdatedTimestamp = vacancy.UpdatedTimestamp,
                        UpdatedUserID    = vacancy.UpdatedUserID
                    });

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #10
0
        internal static async Task DeleteSupplierBranchLocation(long Id, string type)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblSupplierLocationBranch obj = new tblSupplierLocationBranch();
                    switch (type)
                    {
                    case "Location":
                        obj = await db.tblSupplierLocationBranches.Where(a => a.LocationID == Id).SingleAsync();

                        break;

                    case "Branch":
                        obj = await db.tblSupplierLocationBranches.Where(a => a.BranchID == Id).SingleAsync();

                        break;
                    }

                    db.tblSupplierLocationBranches.Remove(obj);
                    int x = await Task.Run(() => db.SaveChangesAsync());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #11
0
 internal static async Task <List <tblSupplier> > GetAllSupplierDetails(CompanySearchModel model)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             if (model.companyName == "%")
             {
                 return(await Task.Run(() => db.tblSuppliers
                                       .Include(a => a.tblCountry)
                                       .Include(b => b.tblCountryState)
                                       .Select(x => x).OrderByDescending(x => x.ID).ToList()));
             }
             else
             {
                 return(await Task.Run(() => db.tblSuppliers
                                       .Include(a => a.tblCountry)
                                       .Include(b => b.tblCountryState)
                                       .Where(x => x.Name == model.companyName).OrderByDescending(x => x.ID).ToList()));
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #12
0
 internal static async Task <int> InsertCandidateContacts(tblCandidate can, tblContact con, bool isPrimary)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             var scandidate = db.tblCandidateContacts.Add(new tblCandidateContact
             {
                 ContactID        = con.ID,
                 CandidateID      = can.ID,
                 IsActive         = true,
                 IsDeleted        = false,
                 CreatedTimestamp = can.CreatedTimestamp,
                 CreatedUserID    = can.CreatedUserID,
                 UpdatedTimestamp = can.UpdatedTimestamp,
                 UpdatedUserID    = can.UpdatedUserID,
                 IsPrimary        = isPrimary
             });
             return(await Task.Run(() => db.SaveChangesAsync()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #13
0
        internal static async Task <tblCandidate> Get(long Id)
        {
            IQueryable <tblCandidate> list = null;

            try
            {
                using (db = new eMSPEntities())
                {
                    list = db.tblCandidates
                           .Include(a => a.tblCandidateContacts)
                           .Include(a => a.tblCandidateContacts.Select(b => b.tblContact))
                           .Include(a => a.tblCandidateContacts.Select(b => b.tblContact).Select(c => c.tblCountry))
                           .Include(a => a.tblCandidateContacts.Select(b => b.tblContact).Select(c => c.tblCountryState))
                           .Include(b => b.tblCandidateFiles.Select(a => a.tblFile))
                           .Include(b => b.tblCandidateSkills.Select(a => a.tblIndustrySkill))
                           .Include(b => b.tblCandidateIndustries.Select(a => a.tblIndustry))
                           .Where(x => x.ID == Id && x.IsActive == true && x.IsDeleted == false);


                    return(await Task.Run(() => list.FirstOrDefault()));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #14
0
 internal static async Task <int> InsertSupplierCandidate(tblCandidate can, long supplierId)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             var scandidate = db.tblSupplierCandidates.Add(new tblSupplierCandidate
             {
                 SupplierID       = supplierId,
                 CandidateID      = can.ID,
                 IsActive         = true,
                 IsDeleted        = false,
                 CreatedTimestamp = can.CreatedTimestamp,
                 CreatedUserID    = can.CreatedUserID,
                 UpdatedTimestamp = can.UpdatedTimestamp,
                 UpdatedUserID    = can.UpdatedUserID
             });
             return(await Task.Run(() => db.SaveChangesAsync()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        internal static async Task <tblVacanciesRequiredDocument> AddVacanciesRequiredDocument(tblVacanciesRequiredDocument data, tblVacancy vacancy)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblVacanciesRequiredDocument model = db.tblVacanciesRequiredDocuments.Add(new tblVacanciesRequiredDocument
                    {
                        VacancyID                   = vacancy.ID,
                        RequiredDocumentID          = data.ID,
                        RequiredDocumentName        = data.RequiredDocumentName,
                        RequiredDocumentDescription = data.RequiredDocumentDescription,
                        IsMandatory                 = data.IsMandatory,
                        IsActive         = true,
                        IsDeleted        = false,
                        CreatedTimestamp = vacancy.CreatedTimestamp,
                        CreatedUserID    = vacancy.CreatedUserID,
                        UpdatedTimestamp = vacancy.UpdatedTimestamp,
                        UpdatedUserID    = vacancy.UpdatedUserID
                    });

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #16
0
        internal static async Task UpdateCandidateTimesheet(tblCandidateTimesheet model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    var existingParent = db.tblCandidateTimesheets
                                         .Where(p => p.ID == model.ID)
                                         .Include(p => p.tblCandidateTimesheetHours)
                                         .SingleOrDefault();

                    if (existingParent != null)
                    {
                        db.Entry(existingParent).CurrentValues.SetValues(model);

                        foreach (var existingChild in existingParent.tblCandidateTimesheetHours.ToList())
                        {
                            if (!model.tblCandidateTimesheetHours.Any(c => c.ID == existingChild.ID))
                            {
                                db.tblCandidateTimesheetHours.Remove(existingChild);
                            }
                        }

                        foreach (var childModel in model.tblCandidateTimesheetHours)
                        {
                            var existingChild = existingParent.tblCandidateTimesheetHours
                                                .Where(c => c.ID == childModel.ID)
                                                .SingleOrDefault();

                            if (existingChild != null)
                            {
                                db.Entry(existingChild).CurrentValues.SetValues(childModel);
                            }
                            else
                            {
                                existingParent.tblCandidateTimesheetHours.Add(childModel);
                            }
                        }

                        int x = await Task.Run(() => db.SaveChangesAsync());
                    }
                    else
                    {
                        await Task.Run(() => InsertCandidateTimesheet(model));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #17
0
        internal static async Task <List <tblUserProfile> > GetAllUsers(long Id, string companyType)
        {
            List <tblUserProfile> data = null;

            try
            {
                using (db = new eMSPEntities())
                {
                    switch (companyType)
                    {
                    case "MSP":
                        data = await Task.Run(() => db.tblUserProfiles
                                              .Include(a => a.tblMSPUsers)
                                              .Join(db.tblMSPUsers, a => a.UserID, b => b.UserID, (a, b) => new { a, b })
                                              .Where(x => x.b.MSPID == Id && x.b.IsDeleted == false)
                                              .Select(x => x.a)
                                              .OrderByDescending(x => x.UserID)
                                              .ToList());

                        break;

                    case "Customer":
                        data = await Task.Run(() => db.tblUserProfiles
                                              .Include(a => a.tblCustomerUsers)
                                              .Join(db.tblCustomerUsers, a => a.UserID, b => b.UserID, (a, b) => new { a, b })
                                              .Where(x => x.b.CustomerID == Id && x.b.IsDeleted == false)
                                              .Select(x => x.a)
                                              .OrderByDescending(x => x.UserID)
                                              .ToList());

                        break;

                    case "Supplier":
                        data = await Task.Run(() => db.tblUserProfiles
                                              .Include(a => a.tblSupplierUsers)
                                              .Join(db.tblSupplierUsers, a => a.UserID, b => b.UserID, (a, b) => new { a, b })
                                              .Where(x => x.b.SupplierID == Id && x.b.IsDeleted == false)
                                              .Select(x => x.a)
                                              .OrderByDescending(x => x.UserID)
                                              .ToList());

                        break;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(data);
        }
Пример #18
0
 internal static async Task <List <tblMSPPayPeriod> > GetMSPPayPeriods()
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblMSPPayPeriods.ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #19
0
 internal static async Task <tblCountry> GetCountry(long Id)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblCountries.Where(x => x.ID == Id).SingleOrDefault()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #20
0
 internal static async Task <List <tblTimesheetStatu> > GetTimesheetStatus()
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblTimesheetStatus.ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #21
0
 internal static async Task <AspNetRoleGroup> GetRoleGroup(string Id)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.AspNetRoleGroups.Where(x => x.Id == Id).SingleOrDefault()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #22
0
 internal static async Task <List <tblCountry> > GetAllCountries()
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblCountries.Select(a => a).OrderBy(x => x.Name).ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #23
0
 internal static async Task <List <tblCountryState> > GetAllStates(long countryId)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblCountryStates.Where(x => x.CountryID == countryId).OrderByDescending(x => x.ID).ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #24
0
 internal static async Task <List <tblMSPSpendCategory> > GetMSPSpendCategory()
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblMSPSpendCategories.ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #25
0
 internal static async Task <List <tblCandidatePlacement> > GetAllPlacements()
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblCandidatePlacements.ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #26
0
 internal static async Task <List <tblCountryState> > GetAllStates(int Id)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblCountryStates.Where(a => a.CountryID == Id).OrderBy(x => x.Name).ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #27
0
 internal static async Task <List <tblMSPDetail> > GetAllMSPDetails(CompanySearchModel model)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblMSPDetails.Where(x => x.CompanyName == model.companyName).OrderByDescending(x => x.ID).ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #28
0
 internal static async Task <List <tblIndustry> > GetAllIndustries()
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblIndustries.OrderByDescending(x => x.ID).ToList()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 internal static async Task InsertCandidateSubmissionsQuestionsRespons(List <tblCandidateSubmissionsQuestionsRespons> model)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             db.tblCandidateSubmissionsQuestionsResponses.AddRange(model);
             int x = await Task.Run(() => db.SaveChangesAsync());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #30
0
 internal static async Task <tblVacancyFile> GetVacancyFiles(long VacancyId)
 {
     try
     {
         using (db = new eMSPEntities())
         {
             return(await Task.Run(() => db.tblVacancyFiles
                                   .Where(x => x.VacancyID == VacancyId).SingleOrDefault()));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }