Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        internal static async Task <VacancyCreateModel> Insert(VacancyCreateModel model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblVacancy vacancy = await Task.Run(() => InsertVacancy(model.Vacancy.ConvertTotblVacancy()));

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

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

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

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

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

                    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.createdUserID    = vacancy.CreatedUserID;
                            c.createdTimestamp = vacancy.CreatedTimestamp;
                            c.updatedUserID    = vacancy.UpdatedUserID;
                            c.updatedTimestamp = vacancy.UpdatedTimestamp;
                            tblComment comment = await Task.Run(() => ManageComments.InsertComment(c.ConvertTotblComment()));

                            tblVacancyComment vc = db.tblVacancyComments.Add(new tblVacancyComment
                            {
                                CommentID        = comment.ID,
                                VacancyID        = vacancy.ID,
                                IsActive         = true,
                                IsDeleted        = false,
                                CreatedTimestamp = vacancy.CreatedTimestamp,
                                CreatedUserID    = vacancy.CreatedUserID,
                                UpdatedTimestamp = vacancy.UpdatedTimestamp,
                                UpdatedUserID    = vacancy.UpdatedUserID
                            });

                            tblVacancyComment resVC = await Task.Run(() => ManageVacancyComments.CommentVacancy(vc));

                            CommentUsersModel commentUM = new CommentUsersModel
                            {
                                commentId        = comment.ID,
                                userId           = vacancy.CreatedUserID,
                                isActive         = true,
                                isDeleted        = false,
                                createdTimestamp = vacancy.CreatedTimestamp,
                                createdUserID    = vacancy.CreatedUserID,
                                updatedTimestamp = vacancy.UpdatedTimestamp,
                                updatedUserID    = vacancy.UpdatedUserID
                            };

                            tblCommentUser resCommentUser = await Task.Run(() => ManageComments.InsertCommentUser(commentUM.ConvertTotblCommentUser()));
                        }
                    }
                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }