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;
            }
        }
        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;
            }
        }
Esempio n. 3
0
 public static VacancyLocationModel ConvertToVacancyLocation(this tblVacancyLocation data)
 {
     return(new VacancyLocationModel()
     {
         id = data.ID,
         vacancyId = data.VacancyID,
         locationId = data.LocationID,
         locationName = data.tblLocation?.LocationName,
         isActive = data.IsActive,
         isDeleted = data.IsDeleted,
         createdUserID = data.CreatedUserID,
         updatedUserID = data.UpdatedUserID,
         createdTimestamp = data.CreatedTimestamp,
         updatedTimestamp = data.UpdatedTimestamp
     });
 }
Esempio n. 4
0
        internal static async Task <VacancyCreateModel> Update(VacancyCreateModel model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblVacancy vacancy = await Task.Run(() => UpdateVacancy(model.Vacancy.ConvertTotblVacancy()));

                    await Task.Run(() => ManageVacancySkills.DeleteVacancySkills(vacancy.ID));

                    foreach (IndustrySkillsCreateModel a in model.VacancySkills)
                    {
                        tblVacancieSkill vacancySkill = await Task.Run(() => ManageVacancySkills.AddVacancySkills(a.id, vacancy));
                    }

                    await Task.Run(() => ManageVacancySuppliers.UpdateVacancySupplier(vacancy.ID));

                    foreach (CompanyCreateModel a in model.VacancySuppliers)
                    {
                        tblVacancySupplier vacancySupplier = await Task.Run(() => ManageVacancySuppliers.InsertVacancySupplier(a.id, vacancy));
                    }

                    await Task.Run(() => ManageVacancyLocations.DeleteVacancyLocation(vacancy.ID));

                    foreach (LocationCreateModel a in model.VacancyLocations)
                    {
                        tblVacancyLocation vacancyLocation = await Task.Run(() => ManageVacancyLocations.AddVacancyLocation(a.locationId, vacancy));
                    }

                    await Task.Run(() => ManageVacancyFiles.DeleteVacancyFile(vacancy.ID));

                    foreach (VacancyFileModel a in model.VacancyFiles)
                    {
                        tblVacancyFile vacancyFile = await Task.Run(() => ManageVacancyFiles.InsertVacancyFiles(a.ConvertTotblVacancyFile(), vacancy));
                    }

                    await Task.Run(() => ManageVacancyRequiredDocuments.DeleteVacanciesRequiredDocument(vacancy.ID));

                    foreach (VacancyRequiredDocumentViewModel a in model.RequiredDocument.Where(x => x.IsSelected ?? false))
                    {
                        await Task.Run(() => ManageVacancyRequiredDocuments.AddVacanciesRequiredDocument(a.ConvertTotblVacanciesRequiredDocument(), vacancy));
                    }

                    await Task.Run(() => ManageVacancyQuestions.DeleteVacancySkills(vacancy.ID));

                    foreach (VacancyQuestionViewModel a in model.Questions.Where(x => x.IsSelected ?? false))
                    {
                        await Task.Run(() => ManageVacancyQuestions.AddVacanciesQuestions(a.ConvertTotblVacanciesQuestion(), vacancy));
                    }

                    //Comments
                    foreach (CommentModel c in model.VacancyComment)
                    {
                        if (!string.IsNullOrEmpty(c.comment))
                        {
                            c.updatedUserID    = vacancy.UpdatedUserID;
                            c.updatedTimestamp = vacancy.UpdatedTimestamp;
                            tblComment comment = await Task.Run(() => ManageComments.UpdateComment(c.ConvertTotblComment()));
                        }
                    }
                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }