public IEnumerable <Specialist.Model.Specialist> GetSpecialistById(int id) { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; GetSpecialistByIdHandler handler = new GetSpecialistByIdHandler(context); return(handler.Handle(id)); }
public IEnumerable <Specialist.Model.Specialist> GetSpecialistByEmailAndPassword(string email, string password) { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; GetSpecialistByEmailAndPasswordHandler handler = new GetSpecialistByEmailAndPasswordHandler(context); return(handler.Handle(email, password)); }
public IActionResult Login([FromBody] User user) { if (user == null) { return(BadRequest("Invalid client request")); } List <Specialist.Model.Specialist> specialists = new List <Specialist.Model.Specialist>(); SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; GetSpecialistByEmailAndPasswordHandler handler = new GetSpecialistByEmailAndPasswordHandler(context); specialists = handler.Handle(user.Email, user.Password); if (specialists.Count == 1) { var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("superSecretKey@345")); var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256); var tokeOptions = new JwtSecurityToken( issuer: "http://localhost:3000", audience: "http://localhost:3000", claims: new List <Claim>(), expires: DateTime.Now.AddMinutes(5), signingCredentials: signinCredentials ); var tokenString = new JwtSecurityTokenHandler().WriteToken(tokeOptions); return(Ok(new { Token = tokenString })); } else { return(Unauthorized()); } }
public bool UpdateSpecialistPassword(int specialistId, string specialistPassword) { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; UpdateSpecialistPasswordHandler handler = new UpdateSpecialistPasswordHandler(context); return(handler.Handle(specialistId, specialistPassword)); }
public bool UpdateMedicalSpecialist(int id, [FromBody] CreateSpecialistCommand request) { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; UpdateSpecialistHandler handler = new UpdateSpecialistHandler(context); return(handler.Handle(id, request)); }
public MedicalSpecialist GetMedicalSpecialistById(int id) { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; GetSpecialistByIdHandler handler = new GetSpecialistByIdHandler(context); return(handler.Handle(id)); }
public bool WriteAllSpecialistsToXLS() { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; WriteAllSpecialistsToXLSHandler handler = new WriteAllSpecialistsToXLSHandler(context); return(handler.Handle()); }
public IEnumerable <MedicalSpecialist> GetAllMedicalSpecialists() { SpecialistContext context = HttpContext.RequestServices.GetService(typeof(SpecialistContext)) as SpecialistContext; GetAllSpecialistsHandler handler = new GetAllSpecialistsHandler(context); return(handler.Handle()); }
public void GetCourseByIdTest() { // arrange List <MedicalSpecialist> list = new List <MedicalSpecialist>(); int id = 2; MedicalSpecialist expected = new MedicalSpecialist { LastName = "lastname", FirstName = "name", MiddleName = "middlename", Email = "*****@*****.**", PasswordHash = "password", HealthFacilitiesFacultyId = 1, }; //act SpecialistContext context = new SpecialistContext(connString); GetSpecialistByIdHandler handler = new GetSpecialistByIdHandler(context); handler.Handle(id); using (conn = new MySqlConnection(connString)) { conn.Open(); string query = string.Format("select * from specialists where email='*****@*****.**' and last_name='lastname'"); MySqlCommand cmd = new MySqlCommand(query, conn); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { list.Add(new MedicalSpecialist() { Id = Convert.ToInt32(reader["specialist_id"]), LastName = reader["last_name"].ToString(), FirstName = reader["first_name"].ToString(), MiddleName = reader["middle_name"].ToString(), Email = reader["email"].ToString(), HealthFacilitiesFacultyId = Convert.ToInt32(reader["Health_Facilities_faculty_id"]), }); } } } if (list[0].HealthFacilitiesFacultyId == expected.HealthFacilitiesFacultyId && list[0].LastName == expected.LastName && list[0].Email == expected.Email) { Assert.IsTrue(true); } }
public CreateSpecialistHandler(SpecialistContext context) { _context = context; }
public GetSpecialistByEmailAndPasswordHandler(SpecialistContext context) { _context = context; }
public GetSpecialistByIdHandler(SpecialistContext context) { _context = context; }
public WriteAllSpecialistsToXLSHandler(SpecialistContext context) { _context = context; }
public UpdateSpecialistPasswordHandler(SpecialistContext context) { _context = context; }
public GetAllSpecialistsHandler(SpecialistContext context) { _context = context; }
public UpdateSpecialistEmailHandler(SpecialistContext context) { _context = context; }