Esempio n. 1
0
        public async Task <ActionResult> EditEmployee(PageEditEmployerViewModel model, IFormFile Image)
        {
            // var repo = new EmployerRepository(this.dbContext);
            Search_Work.Models.ArreaDatabase.Employer updatEmployer = dbContext.Employers.Include(x => x.AccountUser)
                                                                      .FirstOrDefault(e => e.Id == model.Id);

            if (updatEmployer.Contact == null)
            {
                updatEmployer.Contact = new Search_Work.Models.ArreaDatabase.Contact()
                {
                    Id = Guid.NewGuid(),
                };
            }

            try
            {
                if (Image != null)
                {
                    string     name       = Image.FileName;
                    string     path       = $"/files/{name}";
                    string     serverPath = $"{_environment.WebRootPath}{path}";
                    FileStream fs         = new FileStream(serverPath, FileMode.Create,
                                                           FileAccess.Write);
                    await Image.CopyToAsync(fs);

                    fs.Close();

                    updatEmployer.Contact.Avatar = path;
                }

                updatEmployer.Contact.Surname = model.LastName;
                updatEmployer.Contact.Name    = model.Name;
                updatEmployer.Contact.Phone   = model.PhoneNumber;
                updatEmployer.Contact.Email   = model.Email;
                updatEmployer.Contact.Status  = model.Status;

                //toDo model.Доступ
                //toDo model.Назначити редактора
                // toDo model.Публікація вакансій
                // toDo model.Доступ до билинга

                dbContext.Employers.Update(updatEmployer);
                dbContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(updatEmployer.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction(nameof(EmployeeCompany), new { companyId = model.CompanyId }));
        }
        public ActionResult AddPaternSearchVacancy(AddPaternSearchVacancyViewModel model)
        {
            var fieldAct   = db.FieldActivities.Include(f => f.Vacancies).FirstOrDefault(f => f.Id == model.FieldActivityId);
            var city       = db.Cities.Include(c => c.Vacancies).FirstOrDefault(c => c.Id == model.Id);
            var employment = db.Employments.Include(e => e.Vacancies).FirstOrDefault(e => e.Id == model.EmploymentId);
            var exOfWork   = db.ExperienceOfWorks.Include(e => e.Vacancies).FirstOrDefault(e => e.Id == model.ExperienceOfWorkId);

            var newPaternSearch = new PaternSearchVacancy()
            {
                Id               = Guid.NewGuid(),
                Request          = model.Request,
                Salary           = model.Salary,
                City             = city == null ? Guid.Empty : city.Id,
                Employment       = employment == null ? Guid.Empty : employment.Id,
                FieldActivity    = fieldAct == null ? Guid.Empty : fieldAct.Id,
                ExperienceOfWork = exOfWork == null ? Guid.Empty : exOfWork.Id,
            };

            db.PaternSearchVacancies.Add(newPaternSearch);
            db.SaveChanges();

            return(RedirectToAction(nameof(PaternSearchVacancy)));
        }
        public ActionResult AddFieldActivitiy(AddResumeFieldActivitiesViewModel model)
        {
            var resume = db.Resumes.Include(r => r.Candidate).ThenInclude(r => r.AccountUser)
                         .Include(r => r.FieldActivities).ThenInclude(r => r.FieldActivity)
                         .FirstOrDefault(i => i.Id == model.ResumeId);

            var fieldActivity = db.FieldActivities.FirstOrDefault(e => e.Id == model.FieldActivityId);

            var newFieldActivity = new FieldActivityResume()
            {
                Id            = Guid.NewGuid(),
                Resume        = resume,
                FieldActivity = fieldActivity,
            };

            resume.DateChange = DateTime.Now;
            // newExp.EmploymentId = employment.Id;


            resume.FieldActivities.Add(newFieldActivity);
            db.Update(resume);
            db.SaveChanges();

            return(RedirectToAction("Edit", "Resume", new { resumeId = model.ResumeId }));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(CompanyEditViewModel model, IFormFile Image)
        {
            var companyUpdate = _context.Companies.Include(c => c.City)
                                .Include(c => c.Employers).FirstOrDefault(m => m.Id == model.Id);

            var emplCompany = companyUpdate.Employers.FirstOrDefault(e => e.Id == model.EmployeeId);
            var city        = _context.Cities.Include(c => c.Companies)
                              .FirstOrDefault(c => c.Id == model.CityId);

            //if (ModelState.IsValid)
            {
                Search_Work.Models.ArreaDatabase.Employer emp = null;
                try
                {
                    if (Image != null)
                    {
                        string     name       = Image.FileName;
                        string     path       = $"/files/{name}";
                        string     serverPath = $"{_environment.WebRootPath}{path}";
                        FileStream fs         = new FileStream(serverPath, FileMode.Create,
                                                               FileAccess.Write);
                        await Image.CopyToAsync(fs);

                        fs.Close();
                        companyUpdate.CompanyLogoUrl = path;
                    }

                    emp = _context.Employers.Include(e => e.Company)
                          .Include(e => e.AccountUser).FirstOrDefault(e => e.Id == model.EmployeeId);


                    //     if(companyEmployers == null)
                    if (!companyUpdate.Employers.Contains(emp))
                    {
                        companyUpdate.Employers.Add(emp);
                    }


                    companyUpdate.Name = model.CompanyName;
                    companyUpdate.City = city;
                    //companyUpdate.Requirements = model.Re
                    companyUpdate.Description = model.Description;
                    companyUpdate.PhoneNumber = model.PhoneNumber;
                    companyUpdate.Email       = model.Email;
                    companyUpdate.Site        = model.Site;
                    companyUpdate.Facebook    = model.Facebook;
                    companyUpdate.Adress      = model.Adress;
                    // companyUpdate.Employers = model.Employers;

                    if ((companyUpdate.Status == false && model.Status == true) ||
                        (companyUpdate.Status == true && model.Status == false))
                    {
                        companyUpdate.Status = model.Status;
                    }

                    _context.Companies.Update(companyUpdate);
                    _context.SaveChanges();

                    return(RedirectToAction(nameof(Details), new { id = companyUpdate.Id, empId = emplCompany.Id }));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyExists(companyUpdate.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        //return RedirectToAction("Logout", "Account");
                        return(RedirectToAction(nameof(Details), new { id = companyUpdate.Id, empId = emplCompany.Id }));
                    }
                }
                //return RedirectToAction(nameof(Details), new { id = company.Id, empId = empId });
            }
            // return RedirectToAction(nameof(Details), new { id = companyUpdate.Id, empId = emplCompany.Id });
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(PageEditResumeViewModel model, IFormFile Image)
        {
            Resume updateResume = db.Resumes.Include(r => r.Candidate.AccountUser)
                                  .Include(r => r.Candidate.City)
                                  .Include(r => r.Candidate.FamilyStatus)
                                  .Include(r => r.Candidate.Children)
                                  .Include(r => r.FieldActivities)
                                  .Include(r => r.Educations).ThenInclude(r => r.LevelEducation)
                                  .Include(r => r.Educations).ThenInclude(r => r.FormTraining)
                                  .Include(r => r.Experiences).ThenInclude(r => r.Employment)
                                  .Include(r => r.ImplementedProjects)
                                  .Include(r => r.SoftWares).ThenInclude(r => r.LevelTechnologyPossession)
                                  .Include(r => r.Awards)
                                  .Include(r => r.ForeignLanguages).ThenInclude(r => r.LevelLanguage)
                                  .Include(r => r.TrainingAndCources)
                                  .Include(r => r.AditinalInfo)
                                  .Include(r => r.Publications)
                                  .FirstOrDefault(r => r.Id == model.Id);

            updateResume.Name = model.ResumeName;

            updateResume.IsAnonymousResume = model.IsAnonymousResume;
            updateResume.IsHideContact     = model.IsHideContact;
            updateResume.IsActiveResume    = model.IsActiveResume;



            List <FieldActivity> fieldActivities = null;

            if (model.FieldIds != null)
            {
                foreach (var updateFildAct in updateResume.FieldActivities)
                {
                    foreach (var id in model.FieldIds)
                    {
                        var upFieldActiv = db.FieldActivities.Include(f => f.Vacancies)
                                           .Include(f => f.Resumes).FirstOrDefault(x => x.Id == id);


                        updateFildAct.FieldActivity = upFieldActiv;
                    }
                }
            }

            updateResume.Candidate.LastName = model.LastName;
            updateResume.Candidate.Name     = model.CandidateName;
            updateResume.Candidate.Surname  = model.Surname;

            if (Image != null)
            {
                string     name       = Image.FileName;
                string     path       = $"/files/{name}";
                string     serverPath = $"{_environment.WebRootPath}{path}";
                FileStream fs         = new FileStream(serverPath, FileMode.Create,
                                                       FileAccess.Write);
                await Image.CopyToAsync(fs);

                fs.Close();
                updateResume.Foto = path;
            }



            updateResume.Candidate.Sex      = model.Sex;
            updateResume.Candidate.Birthday = model.Birthday;
            updateResume.Candidate.Email    = model.Email;
            updateResume.Candidate.Facebook = model.Fasebook;
            updateResume.Candidate.Linkedin = model.Linkedin;
            updateResume.Candidate.Skype    = model.Skype;

            updateResume.Candidate.Country         = model.Country;
            updateResume.Candidate.Region          = model.Region;
            updateResume.Candidate.City.Name       = model.CityResident;
            updateResume.Candidate.Street          = model.Street;
            updateResume.Candidate.ApartmentNumber = model.ApartmentNumber;


            var newChildren = db.Childrens.Include(c => c.Candidates)
                              .ThenInclude(can => can.Resumes).FirstOrDefault(c => c.Id == model.ChildrenId);

            updateResume.Candidate.Children = newChildren != null ? newChildren : null;
            //if (newChildren != null)
            //{
            //    updateResume.Candidate.Children = newChildren;
            //}

            // --------------------------------- FamilyStatus ----------------------------

            var newFamilyStatus = db.FamilyStatuses.Include(fam => fam.Candidates)
                                  .ThenInclude(can => can.Resumes).FirstOrDefault(f => f.Id == model.FamilyStatusId);

            updateResume.Candidate.FamilyStatus = newFamilyStatus != null ? newFamilyStatus : null;

            //if (newFamilyStatus != null)
            //{
            //    updateResume.Candidate.FamilyStatus = newFamilyStatus;
            //}

            // ---------------------------------Expirience----------------------------


            if (updateResume.Experiences != null)
            {
                if (model.Experiences != null)
                {
                    foreach (var modelExp in model.Experiences)
                    {
                        var updateExperience = updateResume.Experiences.FirstOrDefault(i => i.Id == modelExp.Id);

                        updateExperience.NameOrganization = modelExp.NameCompany;
                        updateExperience.DateWorkFrom     = modelExp.DateWorkFrom;
                        updateExperience.DateWorkTo       = modelExp.DateWorkTo;
                        updateExperience.IsWorkingNow     = modelExp.IsWorkingNow;

                        // ------------- EMPLOYMENT --------------------------
                        var newEmpl = db.Employments.Include(emp => emp.Experiences).ThenInclude(exp => exp.Resume)
                                      .FirstOrDefault(e => e.Id == modelExp.EmploymentId);
                        updateExperience.Employment = newEmpl != null ? newEmpl : null;


                        updateExperience.Position = modelExp.Position;

                        updateExperience.Task    = modelExp.Task;
                        updateExperience.Progres = modelExp.Progres;
                    }
                }
            }
            // ---------------------------------  Education ----------------------------


            if (updateResume.Educations != null)
            {
                if (model.Educations != null)
                {
                    foreach (var modelEduc in model.Educations)
                    {
                        var updateEduc = updateResume.Educations.FirstOrDefault(e => e.Id == modelEduc.Id);


                        // ------------- LEVEL --------------------------
                        var newLevel = db.LevelEducations.Include(ed => ed.Educations).
                                       ThenInclude(l => l.Resume).FirstOrDefault(l => l.Id == modelEduc.LevelEducationId);
                        updateEduc.LevelEducation = newLevel != null ? newLevel : null;

                        updateEduc.City            = modelEduc.City;
                        updateEduc.NameInstitution = modelEduc.NameInstitution;
                        updateEduc.Specialization  = modelEduc.Specialization;


                        // ------------- FORM_TRAINING  --------------------------
                        var newFormTrain = db.FormTrainings.Include(f => f.Educations).ThenInclude(ed => ed.Resume)
                                           .FirstOrDefault(i => i.Id == modelEduc.FormTrainingId);
                        updateEduc.FormTraining = newFormTrain != null ? newFormTrain : null;
                    }
                }
            }

            // ---------------------------------  Implem progect ----------------------------

            if (updateResume.ImplementedProjects != null)
            {
                if (model.ImplementedProjects != null)
                {
                    foreach (var modelProg in model.ImplementedProjects)
                    {
                        var updateProg = updateResume.ImplementedProjects.FirstOrDefault(e => e.Id == modelProg.Id);

                        updateProg.NameProgect   = modelProg.NameProgect;
                        updateProg.DateWorkFrom  = modelProg.DateWorkFrom;
                        updateProg.DateWorkTo    = modelProg.DateWorkTo;
                        updateProg.LinkToProgect = modelProg.LinkToProgect;
                    }
                }
            }



            // ---------------------------------  Lenguages ----------------------------

            if (updateResume.ForeignLanguages != null)
            {
                if (model.ForeignLanguages != null)
                {
                    foreach (var modelLen in model.ForeignLanguages)
                    {
                        var updateLenguage = updateResume.ForeignLanguages.FirstOrDefault(e => e.Id == modelLen.Id);

                        updateLenguage.Name = modelLen.Name;

                        // ------------- LEVEL --------------------------
                        var newLevel = db.LevelLanguages
                                       .Include(ed => ed.ForeignLanguages).
                                       ThenInclude(l => l.Resume).FirstOrDefault(l => l.Id == modelLen.LevelLanguageId);
                        updateLenguage.LevelLanguage = newLevel != null ? newLevel : null;
                    }
                }
            }


            //// ---------------------------------  Training and course ----------------------------
            if (updateResume.TrainingAndCources != null)
            {
                if (model.TrainingAndCourses != null)
                {
                    foreach (var modelCourse in model.TrainingAndCourses)
                    {
                        var updateCourse = updateResume.TrainingAndCources.FirstOrDefault(e => e.Id == modelCourse.Id);

                        updateCourse.Name                = modelCourse.Name;
                        updateCourse.DateFrom            = modelCourse.DateFrom;
                        updateCourse.DateTo              = modelCourse.DateTo;
                        updateCourse.NumberCertification = modelCourse.NumberSertifikation;
                    }
                }
            }


            //// ---------------------------------  SoftWear ----------------------------

            // var repoLevSoft = new LevelTechnologyPossessionRepository(this.dbContext);

            if (updateResume.SoftWares != null)
            {
                if (model.Softwares != null)
                {
                    foreach (var modelSoftWere in model.Softwares)
                    {
                        var updateSoftWare = updateResume.SoftWares.FirstOrDefault(e => e.Id == modelSoftWere.Id);

                        updateSoftWare.Name = modelSoftWere.Name;

                        //--------------- ------------- LEVEL --------------------------
                        var newlevelSoft = db.LevelTechnologyPossessions
                                           .Include(i => i.SoftWares).ThenInclude(i => i.Resume.Candidate).FirstOrDefault(l => l.Id == modelSoftWere.Id);
                        updateSoftWare.LevelTechnologyPossession = newlevelSoft != null ? newlevelSoft : null;
                    }
                }
            }


            //// ---------------------------------  Awards ----------------------------

            if (updateResume.Awards != null)
            {
                if (model.Awards != null)
                {
                    foreach (var modelAward in model.Awards)
                    {
                        var updateAward = updateResume.Awards.FirstOrDefault(e => e.Id == modelAward.Id);

                        updateAward.Name           = modelAward.Name;
                        updateAward.Date           = modelAward.Date;
                        updateAward.SiteUrlEdition = modelAward.SiteUrlEdition;
                    }
                }
            }

            //// ---------------------------------  Publication ----------------------------

            //if (model.Publications != null)
            //{
            //  foreach (var modelPublic in model.Publications)
            //  {
            //    var updatePublic = updateResume.Publications.FirstOrDefault(e => e.Id == modelPublic.Id);

            //    updatePublic.Name = modelPublic.Name;
            //    updatePublic.Date = modelPublic.Date;
            //    updatePublic.SiteEdition = modelPublic.SiteEdition;

            //  }
            //}

            //// ---------------------------------  Recomendation ----------------------------



            if (!string.IsNullOrEmpty(model.AditinalInfos))
            {
                if (updateResume.AditinalInfo == null)
                {
                    updateResume.AditinalInfo = new AditinalInfo()
                    {
                        Id     = Guid.NewGuid(),
                        Text   = model.AditinalInfos,
                        Resume = updateResume
                    };
                }
                else
                {
                    updateResume.AditinalInfo.Text = model.AditinalInfos;
                }
            }
            //else
            //{
            //    updateResume.AditinalInfo.Text = null;
            //}

            updateResume.DateChange = DateTime.Now;

            db.Resumes.Update(updateResume);
            db.SaveChanges();

            return(RedirectToAction(nameof(Edit), new { resumeId = updateResume.Id }));
        }
Esempio n. 6
0
        public ActionResult Create(CreateVacancyViewModel model)
        {
            // Employer IDENTITY
            var userName = this.HttpContext.User.Identity.Name;

            var employer = dbContext.Employers.Include(e => e.AccountUser)
                           .Include(e => e.Contact)
                           .Include(e => e.Company)
                           .Include(e => e.Vacancies).FirstOrDefault(x => x.AccountUser.UserName == userName);


            // ---------------- Company data ----------------------

            //var company = repoComp.GetAll().Include(c => c.Employers).ThenInclude(c => c.Vacancies)
            //                               .ThenInclude(c => c.Employer)
            //                                .FirstOrDefault(comp => comp.Id == employer.CompanyId);


            var city = dbContext.Cities.Include(i => i.Vacancies)
                       .Include(i => i.Companies)
                       .Include(i => i.Candidates).FirstOrDefault(c => c.Id == model.CityId);

            var fieldActivity = dbContext.FieldActivities.Include(f => f.Vacancies)
                                .Include(f => f.Resumes).FirstOrDefault(x => x.Id == model.FieldActivityId);


            var employment = dbContext.Employments.Include(e => e.Vacancies)
                             .FirstOrDefault(e => e.Vacancies.Select(i => i.Id == model.EmploymentId) != null);

            var expOfWork = dbContext.ExperienceOfWorks.Include(e => e.Vacancies).FirstOrDefault(ex => ex.Id == model.ExperienceOfWorkId);

            var newVacancy = new Vacancy();

            newVacancy.Id   = Guid.NewGuid();
            newVacancy.Name = model.Name;

            newVacancy.Wage       = model.Salary;
            newVacancy.DateCreate = DateTime.Now;

            // toDo DataPublication

            if (fieldActivity != null)
            {
                newVacancy.FieldActivity = fieldActivity;
            }

            if (employer != null)
            {
                newVacancy.Employer = employer;
            }

            if (city != null)
            {
                newVacancy.City = city;
            }
            if (employment != null)
            {
                newVacancy.TypeEmployment = employment;
            }
            if (expOfWork != null)
            {
                newVacancy.ExperienceOfWork = expOfWork;
            }

            newVacancy.Description      = model.Description;
            newVacancy.Requirement      = model.Requirement;
            newVacancy.Responsibilities = model.Responsibilitie;
            newVacancy.ForeignLanguages = model.ForeignLanguages;


            if (model.UseCompanyContact == false && model.UsePersonalContact == false)
            {
                newVacancy.EmailPerson       = model.EmailContactPerson;
                newVacancy.PhoneNumberPerson = model.PhoneNumberContactPerson;
                newVacancy.ContactNamePerson = model.ContactPerson;
            }
            else if (model.UsePersonalContact == true)
            {
                newVacancy.ContactNamePerson = employer.Contact.Email;
                newVacancy.PhoneNumberPerson = employer.Contact.Phone;
                newVacancy.EmailPerson       = employer.Contact.Email;

                newVacancy.IsUsePersonalContact = model.UsePersonalContact;
            }
            else if (model.UseCompanyContact == true)
            {
                newVacancy.ContactNamePerson = employer.Company.Email;
                newVacancy.PhoneNumberPerson = employer.Company.PhoneNumber;
                newVacancy.EmailPerson       = employer.Company.Email;

                newVacancy.IsUseCompanyContact = model.UseCompanyContact;
            }

            newVacancy.Status = "Архів";

            dbContext.Vacancies.Add(newVacancy);
            dbContext.SaveChanges();

            return(RedirectToAction(nameof(EditVacancy), new { vacancyId = newVacancy.Id }));
        }
Esempio n. 7
0
        public async Task <ActionResult> AddResume(AddResumeViewModel model, IFormFile Image)
        {
            var candidate = db.Candidates.Include(c => c.AccountUser)
                            .FirstOrDefault(x => x.Id == model.CandidateId);

            var newResume = new Resume()
            {
                Id   = Guid.NewGuid(),
                Name = model.Name,
                // FieldActivities.
            };
            FieldActivityResume fieldActResume = null;

            var fieldActivity = db.FieldActivities.FirstOrDefault(f => f.Id == model.FieldId);

            if (fieldActivity != null)
            {
                fieldActResume = new FieldActivityResume()
                {
                    Resume        = newResume,
                    Id            = Guid.NewGuid(),
                    FieldActivity = fieldActivity,
                };
            }

            newResume.Candidate = candidate;

            if (Image != null)
            {
                string     name       = Image.FileName;
                string     path       = $"/files/{name}";
                string     serverPath = $"{_environment.WebRootPath}{path}";
                FileStream fs         = new FileStream(serverPath, FileMode.Create,
                                                       FileAccess.Write);
                await Image.CopyToAsync(fs);

                fs.Close();
                newResume.Foto = path;
            }


            newResume.Salary = model.Salary;

            // Todo AnonimResume  IsAnonymousResume

            newResume.Candidate.LastName = model.LastName;
            newResume.Candidate.Name     = model.Name;

            newResume.Candidate.Surname  = model.Surname;
            newResume.Candidate.Sex      = model.Sex;
            newResume.Candidate.Birthday = model.Birthday;
            // Todo Phones ????
            newResume.Candidate.PhoneNumber = model.Phone;
            newResume.Candidate.Email       = model.Email;
            newResume.Candidate.Facebook    = model.Fasebook;
            newResume.Candidate.Linkedin    = model.Linkedin;
            newResume.Candidate.Skype       = model.Skype;

            newResume.DateCreate = DateTime.Now;
            newResume.DateChange = DateTime.Now;


            newResume.Candidate.Country = model.Country;
            newResume.Candidate.Region  = model.Region;
            // newResume.Candidate.City = city;
            newResume.Candidate.Street          = model.Street;
            newResume.Candidate.ApartmentNumber = model.ApartmentNumber;

            db.Resumes.Add(newResume);
            db.SaveChanges();

            return(RedirectToAction(nameof(ResumeController.Edit), "Resume", new { resumeId = newResume.Id }));

            // return Redirect("Edit", "Resume", new { resumeId  == newResume.Id});
        }
        public ActionResult AboutResume(Guid resumeId, Guid?vacancyId)
        {
            var resume = dbContext.Resumes.Include(r => r.Candidate).ThenInclude(c => c.AccountUser)
                         .Include(r => r.Candidate).ThenInclude(c => c.City)
                         .Include(r => r.FieldActivities)
                         .Include(r => r.Educations).ThenInclude(r => r.LevelEducation)
                         .Include(r => r.Educations).ThenInclude(r => r.FormTraining)
                         .Include(r => r.Experiences).ThenInclude(r => r.Employment)
                         .Include(r => r.ImplementedProjects)
                         .Include(r => r.SoftWares).ThenInclude(r => r.LevelTechnologyPossession)
                         .Include(r => r.Awards)
                         .Include(r => r.ForeignLanguages).ThenInclude(r => r.LevelLanguage)
                         .Include(r => r.TrainingAndCources)
                         .Include(r => r.AditinalInfo)
                         .Include(r => r.Publications)
                         .FirstOrDefault(x => x.Id == resumeId);



            var candidateName = $"{ resume.Candidate.Surname } { resume.Candidate.Name } { resume.Candidate.LastName }";

            // Similar resume
            var resumes = dbContext.Resumes.Include(r => r.Candidate).ThenInclude(c => c.AccountUser)
                          .Include(r => r.Candidate)
                          .Include(r => r.Candidate).ThenInclude(c => c.City)
                          .Include(r => r.Experiences).ToList();

            dbContext.Employments.Load();

            // -------------------------------------------------- View -------------------------


            //var repoViewRes = new ViewPageRepository(this.dbContext);
            //var emplRepo = new EmployerRepository(this.dbContext);


            Employer emp = HttpContext.User != null?dbContext.Employers.Include(e => e.AccountUser)
                           .Include(e => e.Company)
                           .Include(e => e.Vacancies).FirstOrDefault(x => x.AccountUser.UserName == HttpContext.User.Identity.Name) : null;



            ViewPage viewResume = new ViewPage();

            viewResume.Id       = Guid.NewGuid();
            viewResume.Resume   = resume;
            viewResume.DataView = DateTime.Now;
            viewResume.Employer = emp;

            dbContext.ViewsPages.Add(viewResume);
            dbContext.SaveChanges();



            var similarResumes = new List <SimilarResumeViewModel>();

            similarResumes.AddRange(resumes.Take(6).Select(resum => new SimilarResumeViewModel()
            {
                ResumeName     = resum.Name,
                Salary         = resum.Salary,
                Birthday       = resum.Candidate.Birthday,
                CityName       = resum.Candidate.City?.Name,
                TypeEmployment = resum.Experiences.Select(ex => ex.Employment).FirstOrDefault(),

                Link = Url.Action("AboutResume", "ResumeHome", new { resumeId = resume.Id }),
            }));


            string fam = resume.Candidate?.FamilyStatus?.Name;

            // var repoLevel = new LevelEducationRepository(this.dbContext);

            PageAboutResumeViewModel model = new PageAboutResumeViewModel();


            model.NameCanditate = candidateName;
            model.DataCriate    = resume.DateCreate;

            model.CityName = resume.Candidate.City?.Name;

            model.IsAnonimus = resume.IsAnonymousResume;

            model.ResumeName = resume.Name;
            model.ResumeId   = resumeId;
            model.VacancyId  = vacancyId;

            if (emp != null)
            {
                model.EmpViewId = emp.Id;
            }


            model.Foto = resume.Foto;

            model.Wage = resume.Salary;


            //if (resume.IsAnonymousResume)
            //{
            //  // Todo resume.IsAnonymousResume
            //}
            //else if (resume.IsHideContact)
            //{
            //  // Todo resume.IsHideContact
            //}

            model.Birthday = resume.Candidate.Birthday;



            model.FamilyStatus = resume.Candidate?.FamilyStatus?.Name;
            model.Children     = resume.Candidate?.Children?.Name;

            model.PhoneNumber = resume.Candidate.PhoneNumber;
            model.Email       = resume.Candidate.Email;
            model.Linkedin    = resume.Candidate.Linkedin;
            model.Fasebook    = resume.Candidate.Facebook;
            model.Skype       = resume.Candidate.Skype;



            model.Educations = resume.Educations?.Select(e => new EducationViewModel()
            {
                LevelEducation  = e.LevelEducation,
                NameInstitution = e.NameInstitution,
                Specialization  = e.Specialization,
                DateWorkFrom    = e.DateWorkFrom,
                DateWorkTo      = e.DateWorkTo
            }).ToList();

            model.Experiences = resume.Experiences?.Select(i => new ExperienceViewModel()
            {
                NameCompany  = i.NameOrganization,
                DateWorkFrom = i.DateWorkFrom,
                DateWorkTo   = i.DateWorkTo,
                Position     = i.Position,
                Task         = i.Task,
                Progres      = i.Progres
            }).ToList();

            model.ImplementProjects = resume.ImplementedProjects?.Select(proj => new ImplementedProjectViewModel()
            {
                NameProgect   = proj.NameProgect,
                DateWorkFrom  = proj.DateWorkFrom,
                DateWorkTo    = proj.DateWorkTo,
                LinkToProgect = proj.LinkToProgect
            }).ToList();



            model.TrainingAndCources = resume.TrainingAndCources?.Select(сourse => new TrainingAndCourceViewMopdel()
            {
                Name     = сourse.Name,
                DateFrom = сourse.DateFrom,
                DateTo   = сourse.DateTo,
            }).ToList();

            model.Awards = resume.Awards.Select(award => new AwardViewModel()
            {
                Name = award.Name,
                Date = award.Date
            }).ToList();

            model.Publications = resume.Publications.Select(p => new PublicationViewModel()
            {
                Name = p.Name,
                Date = p.Date
            }).ToList();

            model.Softwares = resume.SoftWares.Select(soft => new SoftwareViewModel()
            {
                Name          = soft.Name,
                LevelSoftWare = soft.LevelTechnologyPossession.Name
            }).ToList();
            model.ForeignLanguages = resume.ForeignLanguages.Select(len => new ForeignLanguageViewModel()
            {
                Name          = len.Name,
                LevelLanguage = len.LevelLanguage.Name
            }).ToList();

            model.SimilarResume = similarResumes;



            return(View("/Views/Home/HomeResume/PageAboutResume.cshtml", model));
        }
Esempio n. 9
0
        public ActionResult AboutVacancy(Guid vacancyId)
        {
            var vacancy = dbContext.Vacancies.Include(v => v.Employer).ThenInclude(e => e.AccountUser)
                          .Include(v => v.FieldActivity)
                          .Include(v => v.Employer).ThenInclude(e => e.Company)
                          .Include(v => v.TypeEmployment)
                          .Include(v => v.ExperienceOfWork)
                          .Include(v => v.City)
                          .FirstOrDefault(v => v.Id == vacancyId);


            // -------------------------------------------------- View -------------------------

            // var viewVacRepo = new ViewPageRepository()


            Candidate candidate = HttpContext.User != null?
                                  dbContext.Candidates.Include(e => e.AccountUser).Include(c => c.Resumes)
                                  .FirstOrDefault(x => x.AccountUser.UserName == HttpContext.User.Identity.Name) : null;

            var viewVac = new Models.ArreaDatabase.Resumes.ViewPage();

            viewVac.Id        = Guid.NewGuid();
            viewVac.Vacancy   = vacancy;
            viewVac.DataView  = DateTime.Now;
            viewVac.Candidate = candidate;
            // viewVac.ResumeId = null;

            dbContext.ViewsPages.Add(viewVac);
            dbContext.SaveChanges();


            // Similar vacancy
            var vacanciesSimilar = dbContext.Vacancies
                                   .Include(v => v.Employer).ThenInclude(e => e.Company)
                                   .Include(v => v.City).ToList();
            Random rnd = new Random();

            int countSimilVacancy = rnd.Next();
            var similarVacancy    = new List <SimilarVacanciesViewModel>();

            similarVacancy.AddRange(vacanciesSimilar.Take(5).Select(vacncy => new SimilarVacanciesViewModel()
            {
                VacancyName    = vacancy.Name,
                Salary         = vacncy.Wage,
                CompanyName    = vacncy.Employer?.Company?.Name,
                CityName       = vacncy.City?.Name,
                TypeEmployment = vacancy.TypeEmployment,

                Link = Url.Action("AboutVacancy", "Vacancy", new { vacancyId = vacancy.Id }),
            }));

            var model = new PageAboutVacncyViewModel();

            if (candidate != null)
            {
                model.Candidate = candidate;
            }

            model.DateCriate        = vacancy.DateCreate;
            model.FieldActivityName = vacancy.FieldActivity.Name;
            model.VacancyName       = vacancy.Name;
            model.VacancyId         = vacancyId;

            model.Wage        = vacancy.Wage;
            model.CompanyName = vacancy.Employer?.Company?.Name;
            model.LinkAllVacancyThisCompany = Url.Action("AboutCompany", "CompanyHome", new { companyId = vacancy.Employer.Company.Id });

            model.CompanyLogoUrl   = vacancy.Employer?.Company?.CompanyLogoUrl;
            model.CityName         = vacancy.City?.Name;
            model.TypeEmployment   = vacancy.TypeEmployment?.Name;
            model.ExperienceOfWork = vacancy.ExperienceOfWork?.NameField;


            model.Site     = vacancy.Site;
            model.Linkedin = vacancy.Linkedin;
            model.Fasebook = vacancy.Facebook;

            model.Description            = vacancy.Description;
            model.Responsibilities       = vacancy.Responsibilities;
            model.Requirement            = vacancy.Requirement;
            model.ForeignLanguages       = vacancy.ForeignLanguages;
            model.AdditionalRequirements = vacancy.AdditionalRequirements;

            if (vacancy.IsUseCompanyContact)
            {
                // ToDo ContactPerson - Name contact person
                model.ContactPerson     = vacancy.Employer.AccountUser.Email;
                model.PhoneNumberPerson = vacancy.Employer.Company.PhoneNumber;
                model.EmailPerson       = vacancy.Employer.Company.Email;
            }
            else if (vacancy.IsUsePersonalContact)
            {
                // ??????????????????????????
                model.ContactPerson     = vacancy.Employer.Contact.Name;
                model.PhoneNumberPerson = vacancy.Employer.Company.PhoneNumber;
                model.EmailPerson       = vacancy.Employer.Contact.Email;
            }
            else
            {
                model.ContactPerson     = vacancy.ContactNamePerson;
                model.PhoneNumberPerson = vacancy.PhoneNumberPerson;
                model.EmailPerson       = vacancy.EmailPerson;
            }

            //model.PhoneNumberPerson = vacancy.Employer.Company.PhoneNumber;
            //  model.EmailPerson = vacancy.Employer.Company.Email;



            model.SimilarVacancies = similarVacancy;



            return(View("/Views/Home/HomeVacancy/PageAboutVacancy.cshtml", model));
        }