Класс "Кандидат"
상속: EntityBase
 private static void CreateNewEvents(Candidate destination, CandidateDTO source)
 {
     source.Events.Where(x => x.IsNew()).ToList().ForEach(newEvent =>
     {
         var toDomain = new Event();
         toDomain.Update(newEvent);
         destination.Events.Add(toDomain);
     });
 }
 private static void CreateNewPhoneNumbers(Candidate destination, CandidateDTO source)
 {
     source.PhoneNumbers.Where(x => x.IsNew()).ToList().ForEach(newPhoneNumber =>
     {
         var toDomain = new PhoneNumber();
         toDomain.Update(newPhoneNumber);
         destination.PhoneNumbers.Add(toDomain);
     });
 }
 private static void CreateNewLanguageSkills(Candidate destination, CandidateDTO source)
 {
     source.LanguageSkills.Where(x => x.IsNew()).ToList().ForEach(newLanguageSkill =>
     {
         var toDomain = new LanguageSkill();
         toDomain.Update(newLanguageSkill);
         destination.LanguageSkills.Add(toDomain);
     });
 }
 private static void RefreshExistingEvent(Candidate destination, CandidateDTO source, IRepository<Event> eventRepository)
 {
     source.Events.Where(x => !x.IsNew()).ToList().ForEach(updatedEvent =>
     {
         var domainEvent = destination.Events.FirstOrDefault(x => x.Id == updatedEvent.Id);
         if (domainEvent == null)
         {
             throw new ArgumentNullException("You trying to update event which is actually doesn't exists in database");
         }
         if (updatedEvent.ShouldBeRemoved())
         {
             eventRepository.Delete(updatedEvent.Id);
         }
         else
         {
             domainEvent.Update(updatedEvent);
         }
     });
 }
 private static void PerformVacanciesProgressSaving(Candidate destination, CandidateDTO source, IRepository<VacancyStageInfo> vacancyStageInfoRepository, IRepository<Vacancy> vacancyRepository)
 {
     RefreshExistingVacanciesProgress(destination, source, vacancyStageInfoRepository, vacancyRepository);
     CreateNewVacanciesProgress(destination, source, vacancyRepository);
 }
        public void Init()
        {
            System.Diagnostics.Debug.WriteLine("candidates init");

            context = GenerateNewContext();

            context.Tags.AddRange(DummyData.Tags);
            context.Currencies.AddRange(DummyData.Currencies);
            context.Skills.AddRange(DummyData.Skills);
            context.EventTypes.AddRange(DummyData.EventTypes);
            context.SocialNetworks.AddRange(DummyData.Socials);
            context.Tags.AddRange(DummyData.Tags);
            context.Industries.AddRange(DummyData.Industries);
            context.Levels.AddRange(DummyData.Levels);
            context.DepartmentGroups.AddRange(DummyData.DepartmentGroups);
            context.Departments.AddRange(DummyData.Departments);
            context.Languages.AddRange(DummyData.Languages);
            context.LanguageSkills.AddRange(DummyData.LanguageSkills);
            context.Countries.AddRange(DummyData.Countries);
            context.Cities.AddRange(DummyData.Cities);
            context.Stages.AddRange(DummyData.Stages);
            context.Permissions.AddRange(DummyData.Permissions);
            context.Roles.AddRange(DummyData.Roles);
            context.Users.Add(DummyData.Users.First());
            context.Sources.AddRange(DummyData.Sources);
            context.Vacancies.Add(DummyData.Vacancies.First());
            context.SaveChanges();

            var candidate = new Candidate
            {
                CityId = 1,
                BirthDate = new DateTime(1980, 1, 1),
                Comments = new List<Comment> { new Comment { Message = "someComment" } },
                Education = "education",
                FirstName = "first name",
                IndustryId = 1,
                Description = "description",
                Email = "*****@*****.**",
                Files = new List<File>(),
                IsMale = true,
                LanguageSkills = new List<LanguageSkill> { new LanguageSkill { LanguageId = 1, LanguageLevel = null } },
                LastName = "last name",
                MiddleName = "middlename",
                PhoneNumbers = new List<PhoneNumber>() { new PhoneNumber { Number = "+38098989898" } },
                Photo = new File { Description = "description", FilePath = "description" },
                PositionDesired = "position",
                Practice = "practice",
                RelocationAgreement = false,
                SalaryDesired = 3000,
                Skills = new List<Skill> { DummyData.Skills.First() },
                Skype = "skyper",
                SocialNetworks = new List<CandidateSocial>() { new CandidateSocial { SocialNetworkId = 1, Path = "path" } },
                Sources = new List<CandidateSource> { },
                StartExperience = new DateTime(2000, 1, 1),
                Tags = new List<Tag>() { DummyData.Tags.First() },
                TypeOfEmployment = TypeOfEmployment.FullTime,
                Level = DummyData.Levels.First(),
                VacanciesProgress = new List<VacancyStageInfo>(),
                Events = new List<Event> { new Event { EventDate = new DateTime(2001, 1, 1), CandidateId = 1, EventTypeId = 1, Description = "someDescr", ResponsibleId = 1 } }
            };

            int vacancyId = context.Vacancies.First().Id;
            candidate.VacanciesProgress.Add(new VacancyStageInfo
            {

            });
            candidate.Sources.Add(new CandidateSource { Candidate = candidate, Path = "path", SourceId = context.Sources.First().Id });

            context.Candidates.Add(candidate);

            context.SaveChanges();

            IUnitOfWork uow = new UnitOfWork(context);
            CandidateService service = new CandidateService(uow);

            controller = new CandidateController(service);
        }
 private static void RefreshExistingSources(Candidate destination, CandidateDTO source, IRepository<CandidateSource> candidateSourceRepository)
 {
     source.Sources.Where(x => !x.IsNew()).ToList().ForEach(updatedSource =>
     {
         var domainSource = destination.Sources.FirstOrDefault(x => x.Id == updatedSource.Id);
         if (domainSource == null)
         {
             throw new ArgumentNullException("Request contains unknown entity");
         }
         if (updatedSource.ShouldBeRemoved())
         {
             candidateSourceRepository.Delete(updatedSource.Id);
         }
         else
         {
             domainSource.Update(updatedSource);
         }
     });
 }
 private static void RefreshExistingRelocationPlaces(Candidate destination, CandidateDTO source, IRepository<City> locationRepo)
 {
     source.RelocationPlaces.Where(x => !x.IsNew()).ToList().ForEach(updatedRelocationPlace =>
     {
         var domainRL = destination.RelocationPlaces.ToList().FirstOrDefault(x => x.Id == updatedRelocationPlace.Id);
         if (domainRL == null)
         {
             throw new ArgumentNullException("Request contains unknown entity");
         }
         if (updatedRelocationPlace.ShouldBeRemoved())
         {
             destination.RelocationPlaces.Remove(domainRL);
         }
         else
         {
             domainRL.Update(updatedRelocationPlace);
         }
     });
 }
 private static void PerformPhoneNumbersSaving(Candidate destination, CandidateDTO source, IRepository<PhoneNumber> phoneNumberRepository)
 {
     RefreshExistingPhoneNumbers(destination, source, phoneNumberRepository);
     CreateNewPhoneNumbers(destination, source);
 }
예제 #10
0
 private static void PerformLanguageSkillsSaving(Candidate destination, CandidateDTO source, IRepository<LanguageSkill> languageSkillRepository)
 {
     CreateNewLanguageSkills(destination, source);
     RefreshExistingLanguageSkills(destination, source, languageSkillRepository);
 }
예제 #11
0
 private static void PerformFilesSaving(Candidate destination, CandidateDTO source, IRepository<File> fileRepository)
 {
     source.Files.ToList().ForEach(file =>
     {
         var fileInCandidate = destination.Files.FirstOrDefault(x => x.Id == file.Id);
         var dbFile = fileRepository.GetByID(file.Id);
         if (dbFile == null)
         {
             throw new Exception("Database doesn't contains such entity");
         }
         if (file.ShouldBeRemoved())
         {
             fileRepository.Delete(file.Id);
         }
         else
         {
             dbFile.Update(file);
             if (fileInCandidate == null)
             {
                 destination.Files.Add(dbFile);
             }
         }
     });
 }
예제 #12
0
 private static void PerformEventsSaving(Candidate destination, CandidateDTO source, IRepository<Event> eventRepository)
 {
     RefreshExistingEvent(destination, source, eventRepository);
     CreateNewEvents(destination, source);
 }
예제 #13
0
 private static void PerformCommentsSaving(Candidate destination, CandidateDTO source, IRepository<Comment> commentRepository)
 {
     RefreshExistingComments(destination, source, commentRepository);
     CreateNewComments(destination, source);
 }
예제 #14
0
 private static void CreateNewVacanciesProgress(Candidate destination, CandidateDTO source, IRepository<Vacancy> vacancyRepo)
 {
     source.VacanciesProgress.Where(x => x.IsNew()).ToList().ForEach(newVacancyStageInfo =>
     {
         var toDomain = new VacancyStageInfo();
         toDomain.Update(vacancyRepo.GetByID(newVacancyStageInfo.VacancyId.Value), newVacancyStageInfo);
         destination.VacanciesProgress.Add(toDomain);
     });
 }
예제 #15
0
 private static void CreateNewSources(Candidate destination, CandidateDTO source)
 {
     source.Sources.Where(x => x.IsNew()).ToList().ForEach(newSource =>
     {
         var toDomain = new CandidateSource();
         toDomain.Update(newSource);
         destination.Sources.Add(toDomain);
     });
 }
예제 #16
0
 private static void RefreshExistingLanguageSkills(Candidate destination, CandidateDTO source, IRepository<LanguageSkill> languageSkillRepository)
 {
     source.LanguageSkills.Where(x => !x.IsNew()).ToList().ForEach(updatedLanguageSkills =>
     {
         var domainLS = destination.LanguageSkills.ToList().FirstOrDefault(x => x.Id == updatedLanguageSkills.Id);
         if (domainLS == null)
         {
             throw new ArgumentNullException("Request contains unknown entity");
         }
         if (updatedLanguageSkills.ShouldBeRemoved())
         {
             languageSkillRepository.Delete(updatedLanguageSkills.Id);
         }
         else
         {
             domainLS.Update(updatedLanguageSkills);
         }
     });
 }
예제 #17
0
 private static void RefreshExistingPhoneNumbers(Candidate destination, CandidateDTO source, IRepository<PhoneNumber> phoneNumberRepository)
 {
     source.PhoneNumbers.Where(x => !x.IsNew()).ToList().ForEach(updatedPhoneNumber =>
     {
         var domainPhoneNumber = destination.PhoneNumbers.FirstOrDefault(x => x.Id == updatedPhoneNumber.Id);
         if (domainPhoneNumber == null)
         {
             throw new ArgumentNullException("Request contains unknown entity");
         }
         if (updatedPhoneNumber.ShouldBeRemoved())
         {
             phoneNumberRepository.Delete(updatedPhoneNumber.Id);
         }
         else
         {
             domainPhoneNumber.Update(updatedPhoneNumber);
         }
     });
 }
예제 #18
0
 private static void PerformPhotoSaving(Candidate destination, CandidateDTO source, IRepository<File> fileRepository)
 {
     var photoInDTO = source.Photo;
     if (photoInDTO != null)
     {
         var photoInDb = fileRepository.GetByID(source.Photo.Id);
         if (photoInDb == null)
         {
             throw new Exception("Database doesn't contains such entity");
         }
         if (photoInDTO.ShouldBeRemoved())
         {
             fileRepository.Delete(photoInDb.Id);
         }
         else
         {
             photoInDb.Update(photoInDTO);
             destination.Photo = photoInDb;
         }
     }
 }
예제 #19
0
 private static void RefreshExistingSocials(Candidate destination, CandidateDTO source, IRepository<CandidateSocial> candidateSocialRepository)
 {
     source.SocialNetworks.Where(x => !x.IsNew()).ToList().ForEach(updatedSocial =>
     {
         var domainSocial = destination.SocialNetworks.ToList().FirstOrDefault(x => x.Id == updatedSocial.Id);
         if (domainSocial == null)
         {
             throw new ArgumentNullException("You trying to update candidate social which is actually doesn't exists in database " + "Such as social with id: " + updatedSocial.Id);
         }
         if (updatedSocial.ShouldBeRemoved())
         {
             candidateSocialRepository.Delete(updatedSocial.Id);
         }
         else
         {
             domainSocial.Update(updatedSocial);
         }
     });
 }
예제 #20
0
 private static void PerformRelocationPlacesSaving(Candidate destination, CandidateDTO source, IRepository<City> locationRepo)
 {
     CreateNewRelocationPlaces(destination, source, locationRepo);
     RefreshExistingRelocationPlaces(destination, source, locationRepo);
 }
예제 #21
0
 private static void RefreshExistingVacanciesProgress(Candidate destination, CandidateDTO source, IRepository<VacancyStageInfo> vacancyStageInfoRepository, IRepository<Vacancy> vacancyRepo)
 {
     source.VacanciesProgress.Where(x => !x.IsNew()).ToList().ForEach(updatedVacanciesStageInfo =>
     {
         var domainVacancyStageInfo = destination.VacanciesProgress.FirstOrDefault(x => x.Id == updatedVacanciesStageInfo.Id);
         if (domainVacancyStageInfo == null)
         {
             throw new ArgumentNullException("You trying to update vacancy stage info which is actually doesn't exists in database");
         }
         if (updatedVacanciesStageInfo.ShouldBeRemoved())
         {
             vacancyStageInfoRepository.Delete(updatedVacanciesStageInfo.Id);
         }
         else
         {
             domainVacancyStageInfo.Update(vacancyRepo.GetByID(domainVacancyStageInfo.VacancyId), updatedVacanciesStageInfo);
         }
     });
 }
예제 #22
0
 private static void PerformSkillsSaving(Candidate destination, CandidateDTO source, IRepository<Skill> skillRepository)
 {
     destination.Skills.Clear();
     source.SkillIds.ToList().ForEach(skillId =>
     {
         destination.Skills.Add(skillRepository.GetByID(skillId));
     });
 }
예제 #23
0
 private static void PerformSourcesSaving(Candidate destination, CandidateDTO source, IRepository<CandidateSource> candidateSourceRepository)
 {
     RefreshExistingSources(destination, source, candidateSourceRepository);
     CreateNewSources(destination, source);
 }
예제 #24
0
 private static void PerformTagsSaving(Candidate destination, CandidateDTO source, IRepository<Tag> tagRepository)
 {
     destination.Tags.Clear();
     source.TagIds.ToList().ForEach(tagId =>
     {
         destination.Tags.Add(tagRepository.GetByID(tagId));
     });
 }
예제 #25
0
 private static void CreateNewRelocationPlaces(Candidate destination, CandidateDTO source, IRepository<City> locationRepo)
 {
     source.RelocationPlaces.Where(x => x.IsNew()).ToList().ForEach(newRelocationPlace =>
     {
         var toDomain = DTOService.ToEntity<RelocationPlaceDTO, RelocationPlace>(newRelocationPlace);
         destination.RelocationPlaces.Add(toDomain);
     });
 }
예제 #26
0
 public void UpdateCandidate(Candidate candidate)
 {
     Candidate = candidate;
 }