public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { var candidate = new CandidateService().GetCandidate(model.UserName); if (candidate != null) { base.ViewModel = new ExamViewModel(candidate, null, null, ConfigurationSettings.AppSettings["DefaultExaminerEmail"]); if (new ExamService().HasOpenExams(candidate.Id)) { return(RedirectToAction("Exam", "Exam")); } else { return(RedirectToAction("CategoryTree", "Exam")); } } } ModelState.AddModelError("", "The Email Address or password provided is incorrect."); return(View(model)); }
public ActionResult InActivateResource(int candidateId, int reasonId) { if (UserRoles.UserCanEdit() == true) { if (ModelState.IsValid) { bool model = false; model = CandidateService.InActivateResource(candidateId, reasonId).Result; if (model) { return new JsonResult { Data = "The update is successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet } } ; else { return new JsonResult { Data = "Error has occurred. Contact site support.", JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } return(View()); } else { return(RedirectToAction("Index", "Candidates")); } }
void searchErKaj() { if (konta == 1) { CandidateService cs = new CandidateService(); List <Candidate> cndList = cs.getAllByName(textBox1.Text); cndGridView.DataSource = cndList; } if (konta == 2) { CandidateService cs = new CandidateService(); List <Candidate> cndList = cs.getAllByName(textBox1.Text); cndGridView2.DataSource = cndList; } if (konta == 3) { CollegeService cs = new CollegeService(); List <College> clgList = cs.getAllByName(textBox1.Text); clgGridView.DataSource = clgList; } if (konta == 4) { List <stuClg> filteredStuClgList = new List <stuClg>(); foreach (stuClg can in stuClgList) { if (can.StudentName.ToLower().Contains(textBox1.Text.ToLower())) { filteredStuClgList.Add(can); } } finGridView.DataSource = filteredStuClgList; } }
public async void CandidateSearchTest() { // Arrange var candidates = GetCandidateList(); var searchRequest = new CandidateSearchRequest { Name = "Jason" }; var mockRepo = new Mock <IRepository <Candidate> >(); mockRepo.Setup(m => m.SearchAsync(It.IsAny <Expression <Func <Candidate, bool> > >())) .ReturnsAsync((Expression <Func <Candidate, bool> > predicate) => { return(candidates.Where(predicate.Compile())); }); var candidateService = new CandidateService(mockRepo.Object); // Act var res = await candidateService.SearchAsync(searchRequest); // Assert Assert.Single(res.ToList()); }
public void Z_RemoveCompanyTest() { CandidateService.RemoveCandidate(Candidate); var removedCandidate = CandidateService.GetCandidateFromId(Candidate.Id); Assert.AreEqual(removedCandidate.Id, -1); }
public ActionResult AddReportingResources(ResourceReportingAddDto model) { if (UserRoles.UserCanEdit() == true) { if (ModelState.IsValid) { bool isupdated = CandidateService.AddReportingResources(model); if (isupdated) { //return new JsonResult { Data = "The update has been successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Candidates"); return(Json(new { Url = redirectUrl })); } else { return new JsonResult { Data = "The update is not successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet } }; } return(View(model)); } else { return(RedirectToAction("Index", "Candidates")); } }
public AddCandidatesView(CandidateListViewModel candidateListViewModel, CandidateService candidateService) : this() { _candidateListViewModel = candidateListViewModel; _candidateService = candidateService; _candidateToAdd = new AddCandidateViewModel(candidateService); DataContext = _candidateToAdd; }
public void SaveTeste_When_Update_Id_Not_Exist(int userId, int accelerationId, int companyId) { var fakeContext = new FakeContext("UpdateCandidateNotExist"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <User>(); fakeContext.FillWith <Company>(); fakeContext.FillWith <Acceleration>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var fakeCandidate = new Candidate(); fakeCandidate.UserId = userId; fakeCandidate.AccelerationId = accelerationId; fakeCandidate.CompanyId = companyId; fakeCandidate.Status = 1; fakeCandidate.CreatedAt = DateTime.Today; var service = new CandidateService(context); var actual = service.Save(fakeCandidate); Assert.Equal(fakeCandidate, actual, new CandidateIdComparer()); Assert.Equal(fakeCandidate.Status, actual.Status); Assert.Equal(fakeCandidate.CreatedAt, actual.CreatedAt); } }
public void FindByCompanyIdTest_Return_Right(int companyId, params string[] idCandidatesExpected) { var fakeContext = new FakeContext("Candidate_FindByCompanyId"); fakeContext.FillWith <Candidate>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { List <Candidate> expected = new List <Candidate>(); foreach (var idCandidate in idCandidatesExpected) { var idCandidateInt = idCandidate.Split(',').Select(x => int.Parse(x)).ToList(); expected.Add(fakeContext .GetFakeData <Candidate>() .Find(x => x.UserId == idCandidateInt[0] && x.AccelerationId == idCandidateInt[1] && x.CompanyId == idCandidateInt[2])); } var service = new CandidateService(context); var actual = service.FindByCompanyId(companyId); Assert.Equal(expected, actual, new CandidateIdComparer()); } }
public void Should_Add_New_Candidate_When_Save() { var fakeContext = new FakeContext("SaveNewCandidate"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <User>(); fakeContext.FillWith <Company>(); fakeContext.FillWith <Acceleration>(); var fakeCandidate = new Candidate(); fakeCandidate.UserId = 1; fakeCandidate.AccelerationId = 1; fakeCandidate.CompanyId = 2; fakeCandidate.Status = 1; fakeCandidate.CreatedAt = DateTime.Today; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new CandidateService(context); var actual = service.Save(fakeCandidate); Assert.Equal(fakeCandidate, actual, new CandidateIdComparer()); Assert.Equal(fakeCandidate.Status, actual.Status); Assert.Equal(fakeCandidate.CreatedAt, actual.CreatedAt); } }
public void SaveTeste_When_Update(int userId, int accelerationId, int companyId) { var fakeContext = new FakeContext("UpdateCandidate"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <User>(); fakeContext.FillWith <Company>(); fakeContext.FillWith <Acceleration>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Candidate>() .Find(x => x.UserId == userId && x.AccelerationId == accelerationId && x.CompanyId == companyId); expected.UserId = 1; expected.AccelerationId = 1; expected.CompanyId = 3; expected.Status = 1; expected.CreatedAt = DateTime.Today; var service = new CandidateService(context); var actual = service.Save(expected); Assert.Equal(expected, actual); Assert.Equal(expected.Status, actual.Status); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public async Task <IActionResult> ToggleExclude(int id) { var service = new CandidateService(); await service.ToggleExcludeFlag(id); return(RedirectToAction("Candidate", new { id = id })); }
public async Task <IActionResult> Candidate(int id) { var service = new CandidateService(); var model = await service.GetCandidate(id); return(View(model)); }
public async Task <IActionResult> Index(int page) { var service = new CandidateService(); var model = await service.GetCandidates(page); return(View(model)); }
private void UpdateProc() { if (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { //TODO add message //update candidate name only var newCandidate = OldCandidate; OldCandidate = CandidateService.UpdateCandidate(OldCandidate, NewCandidate); //update candidate qualifications foreach (var v in Qualifications) { if (v.IsSelected) { CandidateQualificationService.AddQualificationToCandidate(new Candidate_Qualification() { Candidate = OldCandidate, Qualification = v.Qualification }); } else { CandidateQualificationService.RemoveQualificationFromCandidate(OldCandidate.Id, v.Qualification.Id); } } //update candidate addresses UpdateCandidateAddresses(); } BackProc(); }
private void AddPlacementAndJobHistory(Opening opening) { //basically put all qualified candidates into each opening. regardless of what conflict there is //TODO CONFLICT case var candidates = CandidateService.GetCandidatesQualifiedForRequiredQualification(opening.RequiredQualificationId); foreach (var v in candidates) { PlacementService.AddPlacementToCandidate(new Placement() { Candidate = v, Opening = opening, Timestamp = DateTime.Now }); var jobHistory = JobHistoryService.AddJobHistory(new JobHistory() { Candidate = v, }); JobHistoryJobService.Add(new JobHistory_Job() { JobHistory = jobHistory, Job = opening.Job }); } }
public HomeController(ILogger <HomeController> logger, CandidateService candidateService, VoteService voteService, ResultService resultService) { _resultService = resultService; _logger = logger; _candidateService = candidateService; _voteService = voteService; }
public async Task Get_All_Candidates_Success() { //Arrange var candidates = new List <Candidate> { new Candidate { FirstName = "Tom", LastName = "Liu", }, new Candidate { FirstName = "John", LastName = "House", }, }; var mockRepo = new Mock <ICandidateRepository>(); mockRepo .Setup(repo => repo.GetCandidatesBySkillsAsync(null)) .ReturnsAsync(candidates); var service = new CandidateService(mockRepo.Object); //Act var ret = await service.GetAllCandidatesAsync(); //Assert Assert.Equal(candidates, ret); }
public ActionResult ExportTimesSheetToExcel() { //var candidateList = new List<CandidateExportModel>(); var candidateList = new List <Candidate>(); if (string.IsNullOrEmpty(Session["FullUserName"].ToString())) { return(RedirectToAction("Login", "Login")); } else { candidateList = CandidateService.CandidateList().Result; GridView gv = new GridView(); gv.DataSource = candidateList; gv.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=ResourceList.xls"); Response.ContentType = "application/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); gv.RenderControl(htw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } return(RedirectToAction("Index", "Candidates")); }
public void GetExamFromAPI() { var examService = new ExamService(); var candidateService = new CandidateService(); var exam = examService.GetLatestOpenExamWithQuestionOptions(candidateService.GetCandidate("*****@*****.**").Id); exam.Questions.ToList().ForEach(x => x.Options.ToList().ForEach(y => { var relatedQuestions = examService.GetRelatedQuestions(y.Id); var answer = new Answer { AnswerText = string.Empty, Level = x.Level, ScorePoint = x.ScorePoint, Id = Guid.NewGuid(), //need to use DbContext.QuestionsOption.Attach() if you want to use this Option = new Option { Id = y.Id, IsSelected = y.IsSelected }, Exam = new Exam { Id = exam.Id, Text = exam.Text } }; var answerReturned = examService.AddAnswer(answer); Debug.WriteLine(relatedQuestions.Count); })); Assert.IsNotNull(exam); }
public ActionResult UpdateCandidate(CandidateEdit candidate) { if (UserRoles.UserCanEdit() == true) { candidate.LoginUser = UserRoles.UserId(); candidate.CandidateAllcaotedResouces.FK_CandidateId = candidate.ID; bool isupdated = CandidateService.EditCandidate(candidate); if (isupdated) { return(new JsonResult { Data = "The update has been successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); // var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Candidates"); // return Json(new { Url = redirectUrl }); } else { return(new JsonResult { Data = "The update is not successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } else { return(RedirectToAction("Index", "Candidates")); } }
public async void CandidateCreateTest() { // Arrange var mock = new Mock <IRepository <Candidate> >(); var candidate = new Candidate() { Name = "Ripal Barot" }; var localCandidate = candidate; mock.Setup(repo => repo.AddAsync(localCandidate)).ReturnsAsync(new Candidate() { Id = 1, Name = "Ripal Barot" }); ICandidateService candidateService = new CandidateService(mock.Object); // Act candidate = await candidateService.AddAsync(candidate); // Assert Assert.Equal("Ripal Barot", candidate.Name); Assert.Equal(1, candidate.Id); }
public EditCandidateViewModel(CandidateViewModel candidateToEdit, CandidateService candidateService) { CandidateToEdit = candidateToEdit; _candidateService = candidateService; CandidateNum = candidateToEdit.CandidateNumber; CopyEditableFields(candidateToEdit); }
private void CreateServices() { var externalService = new ExternalService(); CandidateService = new CandidateService(externalService); VoteService = new VoteService(); ResultService = new ResultService(externalService, VoteService, CandidateService); }
static void Main(string[] args) { var ServiceProvider = new CandidateService(); //ServiceProvider.AddCandidate(); //sServiceProvider.DeleteCandidate(1); ServiceProvider.GetCandidates(); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddSingleton( new GRpcServer("127.0.0.1", 50061, CandidateService.BindService(new CandidateServiceImpl()) ) ); }
public CandidateServiceTest() { _contextoFake = new FakeContext("CandidateTest"); _contextoFake.FillWithAll(); _contexto = new CodenationContext(_contextoFake.FakeOptions); _candidateService = new CandidateService(_contexto); }
public ActionResult SMSBroadcast() { if (string.IsNullOrEmpty(Session["FullUserName"].ToString())) { RedirectToAction("Login", "Login"); } return(View(CandidateService.CandidateList().Result)); }
private CandidateController CandidateController(GeekHunterContext context) { Seed(context); var candidateRepository = new CandidateRepository(context); var candidateService = new CandidateService(candidateRepository); var controller = new CandidateController(candidateService); return(controller); }
public SelectionController(StvContext db) { _db = db; candidateService = new CandidateService(db); credentialService = new CredentialService(db); selectionService = new SelectionService(db); settingService = new SettingService(db); courtService = new CourtService(db); }
public void Init() { System.Diagnostics.Debug.WriteLine("candidates init"); context = GenerateNewContext(); context.Sources.AddRange(DummyData.Sources); context.Countries.AddRange(DummyData.Countries); context.Languages.AddRange(DummyData.Languages); context.SocialNetworks.AddRange(DummyData.Socials); context.Tags.AddRange(DummyData.Tags); context.LanguageSkills.AddRange(DummyData.LanguageSkills); context.Cities.AddRange(DummyData.Cities); context.Industries.AddRange(DummyData.Industries); context.EventTypes.AddRange(DummyData.EventTypes); context.Users.AddRange(DummyData.Users); context.Candidates.AddRange(candidates); context.SaveChanges(); IUnitOfWork uow = new UnitOfWork(context); CandidateService service = new CandidateService(uow); controller = new CandidateController(service); }
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); }
public CandidateController(CandidateService service) { this.service = service; }