public FormProfessors() { InitializeComponent(); this.professorService = new ProfessorService(); this.Text = "Zarządzanie wykładowcami"; this.LoadDataToDataGrid(); }
public FormAddProfessor() { InitializeComponent(); this.scienceTitleService = new ScienceTitleService(); this.professorService = new ProfessorService(); this.LoadToComboBox(); }
public void UpdateAsync_ThrowsValidationException() { Mock.Setup(repo => repo.GetAsync(It.IsAny <int>())) .Returns(GetExceptionTest()); Assert.ThrowsAsync <ValidationException>(async() => await ProfessorService .UpdateAsync(_professorDTO)); }
public void SetUp() { Mock = new Mock <IRepository <Professor> >(); Mock.Setup(repo => repo.GetAllAsync()).Returns(GetAllTest()); Mock.Setup(repo => repo.GetAsync(It.IsAny <int>())) .Returns(GetTest()); ProfessorService = new ProfessorService(Mock.Object, new MapperBll(), new NullLoggerFactory()); }
public ActionResult Cadastrar(ProfessorViewModel professorViewModel) { var professorService = new ProfessorService(); if (professorService.ObterPeloCpf(professorViewModel.Cpf) is var retorno && retorno.EstaValido) { ModelState.AddModelError("", $"O CPF {professorViewModel.Cpf} já está cadastrado"); return(View()); }
public void GivenAProfessorService_WhenCallingAddProfessor_ThenRecieveTheAddedProfessor() { //Given var professorService = new ProfessorService(); //When var actual = professorService.CreateProfessor("hello", "world"); //Then Assert.Equal("world", actual.LastName); }
public void GetAsync_ValidCall() { const int id = 1; var professor = ProfessorService.GetAsync(id).Result; Mock.Verify(m => m.GetAsync(id)); Assert.AreEqual(GetTest().Result.Id, professor.Id); Assert.AreEqual(GetTest().Result.FirstName, professor.FirstName); Assert.AreEqual(GetTest().Result.LastName, professor.LastName); }
public void GivenAProfessorService_WhenCallingGetAllProfessors_ThenRecieveAListWithAllProfessors() { //Given var professorService = new ProfessorService(); //When ICollection <Professor> actual = professorService.GetAllProfessors(); //Then Assert.Equal(3, actual.Count); }
public FormAddMark() { InitializeComponent(); this.markService = new MarkService(); this.studentService = new StudentService(); this.lessonService = new LessonService(); this.professorsService = new ProfessorService(); this.LoadToComboBox(); }
public void GivenAProfessorService_WhenCallingGetProfessor_ThenRecieveProfessor() { //Given var professorService = new ProfessorService(); //When var actual = professorService.GetProfessorById(1); //Then Assert.Equal("Gobelijn", actual.LastName); }
public void GivenAProfessorService_WhenCallingGetProfessorWithNonExistingID_ThenRecieveNull() { //Given var professorService = new ProfessorService(); //When var actual = professorService.GetProfessorById(5); //Then Assert.Null(actual); }
// GET: Login public ActionResult Index() { var alunoService = new AlunoService(); var professorService = new ProfessorService(); var viewModel = new UsuarioViewModel(); viewModel.AlunosLista = alunoService.ListarAlunos().Sucesso.ToList(); viewModel.ProfessoresLista = professorService.ListarProfessores().Sucesso.ToList(); return(View(viewModel)); }
public FormEditMark(Mark markd) { InitializeComponent(); this.markService = new MarkService(); this.studentService = new StudentService(); this.lessonService = new LessonService(); this.professorsService = new ProfessorService(); this.numericUpDown1.Value = markd.MarkNumber; this.LoadToComboBox(markd); this.markId = markd.MarkId; }
public FormEditProfessor(Professor professor) { InitializeComponent(); this.titleScienceService = new ScienceTitleService(); this.professorsService = new ProfessorService(); this.textBox1.Text = professor.FirstName; this.textBox2.Text = professor.LastName; this.LoadToComboBox(professor); this.profId = professor.ProfessorId; }
public void GivenAProfessorService_WhenCallingUpdateProfessor_TheRecieveTheUpdatedProfessor() { //Given var professorService = new ProfessorService(); //When var update = professorService.UpdateProfessor(1, "bart", "simpson"); var actual = professorService.GetProfessorById(1); //Then Assert.Equal("simpson", actual.LastName); }
public void GivenAProfessorService_WhenCallingDeleteProfessor_ThenProfessorIsDeleted() { //Given var professorService = new ProfessorService(); //When professorService.DeleteProfessor(1); var actual = professorService.GetAllProfessors(); //Then Assert.Equal(3, actual.Count); }
public void GetAllAsync_ValidCall() { var professors = ProfessorService.GetAllAsync().Result.ToList(); Mock.Verify(m => m.GetAllAsync()); for (var i = 1; i < GetAllTest().Result.Count(); ++i) { Assert.AreEqual(GetAllTest().Result.ToList()[i].Id, professors[i].Id); Assert.AreEqual(GetAllTest().Result.ToList()[i].FirstName, professors[i].FirstName); Assert.AreEqual(GetAllTest().Result.ToList()[i].LastName, professors[i].LastName); } }
public void TestInitialize() { this._professor1 = ProfessorTestUtils.GetProfessor(); this._professor2 = ProfessorTestUtils.GetProfessor(); this._professorDetailsDto1 = ProfessorTestUtils.GetProfessorDetailsDto(_professor1.Id); this._professorDetailsDto2 = ProfessorTestUtils.GetProfessorDetailsDto(_professor2.Id); this._professorCreatingDto = ProfessorTestUtils.GetProfessorCreatingDto(); this._mockReadRepository = new Mock <IReadRepository>(); this._mockWriteRepository = new Mock <IWriteRepository>(); this._mockProfessorMapper = new Mock <IProfessorMapper>(); _professorService = new ProfessorService(_mockReadRepository.Object, _mockWriteRepository.Object, _mockProfessorMapper.Object); }
public ActionResult Entrar(UsuarioViewModel usuarioViewModel) { AutenticacaoUsuario usuarioParaAutenticar = new AutenticacaoUsuario(); usuarioParaAutenticar.Usuario = AutoMapper.Mapper.Map <Usuario>(usuarioViewModel); UsuarioService usuarioService = new UsuarioService(); var usuarioCadastrado = usuarioService.Autenticar(usuarioParaAutenticar); if (!usuarioCadastrado.EstaValido) { ModelState.AddModelError("", "Senha ou código(s) incorreto(s)."); //ou algum outro problema, investigar return(View("Index")); } else { Session[Login.ChaveUsuarioSession] = usuarioCadastrado.Sucesso; // pra poder gerar o token var professorUsuario = new ProfessorService().ObterPeloIdUsuario(usuarioCadastrado.Sucesso.Usuario.Id); //if (true) { } if (professorUsuario.Sucesso == null && !professorUsuario.EstaValido) { var alunoUsuario = new AlunoService().ObterPeloIdUsuario(usuarioCadastrado.Sucesso.Usuario.Id); if (alunoUsuario.Sucesso == null && !alunoUsuario.EstaValido) { ModelState.AddModelError("", "Erro interno. O código do usuário está cadastrado mas não existe nenhum professor ou aluno com este código."); return(View("Index")); } else { alunoUsuario.Sucesso.Codigo = usuarioCadastrado.Sucesso.Usuario.Codigo; alunoUsuario.Sucesso.Senha = usuarioCadastrado.Sucesso.Usuario.Senha; var autenticacaoAluno = new AutenticacaoAluno(alunoUsuario.Sucesso, usuarioCadastrado.Sucesso.Token); Session[Login.ChaveUsuarioSession] = autenticacaoAluno; return(RedirectToAction("Index", "Home")); } } else { professorUsuario.Sucesso.Codigo = usuarioCadastrado.Sucesso.Usuario.Codigo; professorUsuario.Sucesso.Senha = usuarioCadastrado.Sucesso.Usuario.Senha; var autenticacaoProfessor = new AutenticacaoProfessor(professorUsuario.Sucesso, usuarioCadastrado.Sucesso.Token); Session[Login.ChaveUsuarioSession] = autenticacaoProfessor; return(RedirectToAction("Index", "Home")); } } }
static void Main(string[] args) { ServiceBase <ProfessorDTO> service = new ProfessorService(new DBManagerUOW(new MASV2Context())); service.Insert(new ProfessorDTO() { Name = "Tatjana", LastName = "Stojanovic", City = new CityDTO() { Name = "Belgrade" } }); var smt = service.GetAll(); }
protected void Application_BeginRequest(object sender, EventArgs e) { Response.Headers.Remove("Server"); Response.Headers.Remove("X-Powered-By"); Response.Headers.Remove("X-AspNet-Version"); Response.Headers.Remove("X-AspNetMvc-Version"); HttpContextBase currentContext = new HttpContextWrapper(HttpContext.Current); if (currentContext.Request.Params.AllKeys.Contains("ReturnUrl")) { Response.Redirect("~/Pages/Login"); } if (HttpContext.Current.Cache["ScheduleItem_1"] == null)//(HttpContext.Current.Request.Url.ToString() == WebConfigurationManager.AppSettings["BaseURL"] + "/Pages/SystemManagement/StartService") { RegisterCacheEntry(); } if (HttpContext.Current.Cache["IsRun"] == null) { var _scheduleService = new ScheduleService(new ScheduleRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _termService = new TermService(new TermRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _mappingService = new MappingService(new MappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _collegeService = new CollegeService(new CollegeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalGroupService = new EducationalGroupService(new EducationalGroupRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _professorService = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalClassService = new EducationalClassService(new EducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _studentEducationalClassService = new StudentEducationalClassService(new StudentEducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _professorScoreService = new ProfessorScoreService(new ProfessorScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _indicatorService = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _mappingTypeService = new MappingTypeService(new MappingTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _universityLevelMappingService = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalGroupScoreService = new EducationalGroupScoreService(new EducationalGroupScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _logService = new LogService(new LogRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _logTypeService = new LogTypeService(new LogTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _userService = new UserService(new UserRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var schedule = new ScheduleController(_scheduleService, _termService, _mappingService, _collegeService, _educationalGroupService , _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService , _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService); var schedules = schedule.ListAllSchedules(); foreach (var scheduleItem in schedules) { CheckScheduleTimeLapse("ScheduleItem_" + scheduleItem.Id); } } }
public async Task <IActionResult> BuscarProfessorPorID([FromServices] IUnitOfWork _unitOfWork, int ID) { try { ProfessorModel professor = new ProfessorService(_unitOfWork).BuscarProfessorPorID(ID); if (professor == null) { return(NotFound("Nenhum Registro Encontrado")); } return(Ok(professor)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> BuscarProfessores([FromServices] IUnitOfWork _unitOfWork) { try { List <ProfessorModel> professores = new ProfessorService(_unitOfWork).BuscarProfessores(); if (professores == null || professores.Count.Equals(0)) { return(NotFound("Nenhum Registro Encontrado")); } return(Ok(professores)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static string GetScoreName(this int score, int indicatorId, string professorCode, int termId) { var psCode = Convert.ToInt32(professorCode); if (indicatorId != 4) { IndicatorService indicatorService = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); return(indicatorService.Get(x => x.Id == indicatorId).Scores.OrderBy(s => s.Point) .FirstOrDefault(s => s.Point >= score) ?.Name); } else { var ps = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var universityStudyPlace = ps.Get(x => x.ProfessorCode == psCode && x.Term.Id == termId).UniversityStudyPlace; var ss = new ScoreService(new ScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var ulm = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); if (universityStudyPlace != null && universityStudyPlace > 0) { var scoreId = ulm.Get(x => x.UniversityId == universityStudyPlace).Score.Id; var score1 = ss.Get(x => x.Id == scoreId); if (score1 != null) { return(score1.Name); } else { return(string.Empty); } } else { return(string.Empty); } } //var scoreService = new ScoreService(new ScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); //return scoreService.Get(x => x.Id == scoreId.Value).Name; }
private bool RegisterCacheEntry() { var _scheduleService = new ScheduleService(new ScheduleRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _termService = new TermService(new TermRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _mappingService = new MappingService(new MappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _collegeService = new CollegeService(new CollegeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalGroupService = new EducationalGroupService(new EducationalGroupRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _professorService = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalClassService = new EducationalClassService(new EducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _studentEducationalClassService = new StudentEducationalClassService(new StudentEducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _professorScoreService = new ProfessorScoreService(new ProfessorScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _indicatorService = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _mappingTypeService = new MappingTypeService(new MappingTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _universityLevelMappingService = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalGroupScoreService = new EducationalGroupScoreService(new EducationalGroupScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _logService = new LogService(new LogRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _logTypeService = new LogTypeService(new LogTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _userService = new UserService(new UserRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var schedule = new ScheduleController(_scheduleService, _termService, _mappingService, _collegeService, _educationalGroupService , _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService , _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService); if (HttpContext.Current.Cache["IsRun"] == null) { HttpContext.Current.Cache.Add("IsRun", "True", null, DateTime.MaxValue, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } var schedules = schedule.ListAllSchedules(); foreach (var scheduleItem in schedules) { if (null != HttpContext.Current.Cache["ScheduleItem_" + scheduleItem.Id]) { return(false); } HttpContext.Current.Cache.Add("ScheduleItem_" + scheduleItem.Id, "Test", null, DateTime.MaxValue, TimeSpan.FromMinutes(2), CacheItemPriority.Normal, new CacheItemRemovedCallback(CacheItemRemovedCallback)); } return(true); }
public async Task CheckScheduleTimeLapse(string key) { var log = new List <string>(); log.Add("Test Action 1 at: " + DateTime.Now); //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", log); var _scheduleService = new ScheduleService(new ScheduleRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _termService = new TermService(new TermRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _mappingService = new MappingService(new MappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _collegeService = new CollegeService(new CollegeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalGroupService = new EducationalGroupService(new EducationalGroupRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _professorService = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalClassService = new EducationalClassService(new EducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _studentEducationalClassService = new StudentEducationalClassService(new StudentEducationalClassRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _professorScoreService = new ProfessorScoreService(new ProfessorScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _indicatorService = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _mappingTypeService = new MappingTypeService(new MappingTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _universityLevelMappingService = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _educationalGroupScoreService = new EducationalGroupScoreService(new EducationalGroupScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _logService = new LogService(new LogRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _logTypeService = new LogTypeService(new LogTypeRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var _userService = new UserService(new UserRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var schedule = new ScheduleController(_scheduleService, _termService, _mappingService, _collegeService, _educationalGroupService , _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService , _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService); var sid = Convert.ToDecimal(key.Remove(0, 13)); log.Add("Test Action 2 at: " + DateTime.Now); var sch = schedule.GetSchedule(sid); log.Add("Test Action 3 at: " + DateTime.Now); if (!string.IsNullOrEmpty(sch.ActionMethod) && sch.ActionMethod.LastIndexOf('.') > 0) { await Task.Run(() => { schedule.RunSchedule(sch); }); } log.Add("Test Action 4 at: " + DateTime.Now); }
public ProfessorController(ProfessorService service) { this.service = service; }
public ProfessorsController(ApplicationUserManager userManager, ProfessorService professors) { UserManager = userManager; _professors = professors; }
public async Task DeleteAsync_ValidCall() { await ProfessorService.DeleteAsync(It.IsAny <int>()); Mock.Verify(m => m.Delete(It.IsAny <Professor>())); }
public async Task UpdateAsync_ValidCall() { await ProfessorService.UpdateAsync(_professorDTO); Mock.Verify(m => m.Update(It.IsAny <Professor>())); }
public void GetAllAsync_ThrowsValidationException() { Mock.Setup(repo => repo.GetAllAsync()).Returns(GetAllExceptionTest()); Assert.ThrowsAsync <ValidationException>(async() => await ProfessorService.GetAllAsync()); }