static void Main(string[] args) { HealthContext context = new HealthContext(); //AddPatients(context); //AddDoctors(context); //List<Doctor> doctorList = context.Doctors.ToList(); //foreach (var doctor in doctorList) //{ // UpdateDoctorDetails(doctor, RandomSpecialization(), "Monday to Friday", "10:00 AM to 5:00 PM", "Room A"); //} //context.SaveChanges(); //Doctor doctor = context.Doctors.FirstOrDefault(x => x.FirstName == "Doctor 3"); //Patient patient = context.Patients.FirstOrDefault(x => x.FirstName == "Patient 1"); //DateTime appointmentDate = Convert.ToDateTime("15/09/2020"); //AddAppointment(context, doctor, patient, appointmentDate); //appointmentDate = Convert.ToDateTime("16/09/2020"); //AddAppointment(context, doctor, patient, appointmentDate); //appointmentDate = Convert.ToDateTime("17/09/2020"); //AddAppointment(context, doctor, patient, appointmentDate); //appointmentDate = Convert.ToDateTime("18/09/2020"); //AddAppointment(context, doctor, patient, appointmentDate); //List<Patient> patients = context.Patients.Include; var patients = context.Patients.Include(x => x.Appointments).ToList(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, HealthContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HealthAPI v1")); } app.UseHttpsRedirection(); app.UseRouting(); app.UseCors(); app.UseAuthentication(); app.UseAuthorization(); context.Database.Migrate(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); DummyData.Initialize(app); }
public void Userserivce_Should_NotRegister_Duplicate_Users() { var options = new DbContextOptionsBuilder <HealthContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString() + "HealthCheckTestDB").Options; try { using (var db = new HealthContext(options)) { TestUtils.AddSeedTestData(db); IOptions <AppSettings> appsettings = new MockedAppSetting(); var userService = new UserService(db, appsettings); userService.Register(new Models.DTOs.User.UserRegisterDto { Username = "******", Name = "Enver Gökmen", Email = "*****@*****.**", Gsm = "5069516750", Password = "******" }); } Assert.Fail(); // raises AssertionException } catch (Exception ex) { Assert.AreEqual("This username in use", ex.Message); } }
public WeatherForecastController( HealthContext dbContext, ILogger <WeatherForecastController> logger, IHttpContextAccessor context, SignInManager <ApplicationUser> signInManager) { _logger = logger; _context = context.HttpContext; this.signInManager = signInManager; this.dbContext = dbContext; }
private static void AddAppointment(HealthContext context, Doctor doctor, Patient patient, DateTime appointmentDate) { Appointment appointment = new Appointment(); appointment.DoctorId = doctor.Id; appointment.PatientId = patient.Id; appointment.AppointmentDate = appointmentDate; appointment.Status = "Confirmed"; context.Appointments.Add(appointment); context.SaveChanges(); }
public void TestEfInMemoryAppCountForUser() { var options = new DbContextOptionsBuilder <HealthContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString() + "HealthCheckTestDB").Options; using (var context = new HealthContext(options)) { AddSeedTestData(context); context.SaveChanges(); var count = context.TargetApps.Where(x => x.CreatedById == 1).Count(); Assert.AreEqual(2, count, "Kullnıcı 1'in 2 app'i olması gerekir."); } }
private static void AddSeedTestData(HealthContext context) { context.Users.Add(new User { Id = 1, Name = "Enver Gökmen", Email = "*****@*****.**", Gsm = "5069516750", NotificationPreference = NotificationType.Email }); context.Users.Add(new User { Id = 2, Name = "Diger Kullanıcı", Email = "*****@*****.**", Gsm = "055555555", NotificationPreference = NotificationType.Sms }); context.TargetApps.Add(new TargetApp { Id = 1, Name = "google", Url = "https://www.google.com", CreatedById = 1, IntervalType = IntervalType.Minutely, IntervalValue = 1 }); context.TargetApps.Add(new TargetApp { Id = 2, Name = "google", Url = "https://www.twitter.com", CreatedById = 1, IntervalType = IntervalType.Minutely, IntervalValue = 1 }); context.TargetApps.Add(new TargetApp { Id = 3, Name = "google", Url = "https://www.facebook.com", CreatedById = 2, IntervalType = IntervalType.Minutely, IntervalValue = 1 }); }
public void Health_Checking_Should_Update_Apps_Alive_Status() { var options = new DbContextOptionsBuilder <HealthContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString() + "HealthCheckTestDB").Options; using (var db = new HealthContext(options)) { TestUtils.AddSeedTestData(db); IOptions <AppSettings> appsettings = new MockedAppSetting(); var userService = new UserService(db, appsettings); var jobScheduler = new MockedSchedulerService(); var appService = new TargetAppService(db, jobScheduler); var mockBgService = new MockedBackgroundService(db, userService); var itemToCheck = appService.GetOneToCheck(1); mockBgService.CheckDownOrAlive(itemToCheck); itemToCheck = appService.GetOneToCheck(1); Assert.IsNotNull(itemToCheck.IsAlive, "checking health is not done"); } }
public static List <Patient> GetPatients(HealthContext db) { List <Patient> patients = new List <Patient>() { new Patient { Name = "Jim Jones", Ailments = new List <Ailment>(db.Ailments.Take(2)), Medications = new List <Medication>(db.Medications.Take(2)) }, new Patient { Name = "Ann Smith", Ailments = new List <Ailment>(db.Ailments.Take(1)), Medications = new List <Medication>(db.Medications.OrderBy(m => m.Name).Skip(1).Take(1)) }, new Patient { Name = "Tom Myers", Ailments = new List <Ailment>(db.Ailments.OrderBy(m => m.Name).Skip(2).Take(2)), Medications = new List <Medication>(db.Medications.OrderBy(m => m.Name).Skip(2).Take(2)) } }; return(patients); }
public void Correct_User_Should_Be_Notifited_According_To_Its_Notification_Preference() { var options = new DbContextOptionsBuilder <HealthContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString() + "HealthCheckTestDB").Options; using (var db = new HealthContext(options)) { TestUtils.AddSeedTestData(db); IOptions <AppSettings> appsettings = new MockedAppSetting(); var userService = new UserService(db, appsettings); var curUser = userService.GetById(1); //Email Notification preference by mocked data var jobScheduler = new MockedSchedulerService(); var appService = new TargetAppService(db, jobScheduler); var mockBgService = new MockedBackgroundService(db, userService); var itemToCheck = appService.GetOneToCheck(2, curUser.Id); //app 2 is down mocked var checkUrlResult = mockBgService.CheckDownOrAlive(itemToCheck); Assert.AreEqual(checkUrlResult.UserId, curUser.Id, "Users are not the same"); Assert.IsTrue(checkUrlResult.IsUserNotified, "Users is not Notified"); Assert.IsNotNull(checkUrlResult.NotifiedVia, "Users is not notified (NotifiedVia is null)"); Assert.AreEqual(curUser.NotificationPreference, checkUrlResult.NotifiedVia.Value, "Users's preference was different than notification"); //Check for another Notification preferance for another user, SMS Notification preference by mocked data for user 2 curUser = userService.GetById(2); itemToCheck = appService.GetOneToCheck(3, curUser.Id); //app 3 is down mocked checkUrlResult = mockBgService.CheckDownOrAlive(itemToCheck); Assert.AreEqual(checkUrlResult.UserId, curUser.Id, "Users are not the same"); Assert.IsTrue(checkUrlResult.IsUserNotified, "Users is not Notified"); Assert.IsNotNull(checkUrlResult.NotifiedVia, "Users is not notified (NotifiedVia is null)"); Assert.AreEqual(curUser.NotificationPreference, checkUrlResult.NotifiedVia.Value, "Users's preference was different than notification"); } }
public void User_Should_Not_Be_Notified_If_App_Is_Alive() { var options = new DbContextOptionsBuilder <HealthContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString() + "HealthCheckTestDB").Options; using (var db = new HealthContext(options)) { TestUtils.AddSeedTestData(db); IOptions <AppSettings> appsettings = new MockedAppSetting(); var userService = new UserService(db, appsettings); var curUser = userService.GetById(1); var jobScheduler = new MockedSchedulerService(); var appService = new TargetAppService(db, jobScheduler); var mockBgService = new MockedBackgroundService(db, userService); var itemToCheck = appService.GetOneToCheck(1, curUser.Id); //1 is alive mocked var checkUrlResult = mockBgService.CheckDownOrAlive(itemToCheck); Assert.IsFalse(checkUrlResult.IsUserNotified, "Opps, Users is notified for the alive app"); } }
private static void AddPatients(HealthContext context) { context.Patients.Add(new Patient() { FirstName = "Patient 1", LastName = "Patient 1", Email = "*****@*****.**", Mobile = "300001" }); context.Patients.Add(new Patient() { FirstName = "Patient 2", LastName = "Patient 2", Email = "*****@*****.**", Mobile = "300002" }); context.Patients.Add(new Patient() { FirstName = "Patient 3", LastName = "Patient 3", Email = "*****@*****.**", Mobile = "300003" }); context.Patients.Add(new Patient() { FirstName = "Patient 4", LastName = "Patient 4", Email = "*****@*****.**", Mobile = "300004" }); context.SaveChanges(); }
private static void AddDoctors(HealthContext context) { context.Doctors.Add(new Doctor() { FirstName = "Doctor 1", LastName = "Doctor 1", Email = "*****@*****.**", Mobile = "500001" }); context.Doctors.Add(new Doctor() { FirstName = "Doctor 2", LastName = "Doctor 2", Email = "*****@*****.**", Mobile = "500002" }); context.Doctors.Add(new Doctor() { FirstName = "Doctor 3", LastName = "Doctor 3", Email = "*****@*****.**", Mobile = "500003" }); context.Doctors.Add(new Doctor() { FirstName = "Doctor 4", LastName = "Doctor 4", Email = "*****@*****.**", Mobile = "500004" }); context.SaveChanges(); }
public TokenController(IConfiguration config, HealthContext context) { _configuration = config; _context = context; }
public UsersController(HealthContext _healthContext) { _context = _healthContext; }
public ProvinceRepository(HealthContext context) : base(context) { }
public FeedbacksController(HealthContext context) { _context = context; }
public MockedBackgroundService(HealthContext db, IUserService userService) : base(db, userService) { }
public UserRepository(HealthContext context) : base(context) { }
public SymptomsController(HealthContext context) { _context = context; }
public AdminsController(HealthContext context) { _context = context; }
public MedicalRecordStatusRepository(HealthContext context) : base(context) { }
public AppointmentController(HealthContext context) { _context = context; }
public override void OnActionExecuting(ActionExecutingContext actionContext) { var myController = actionContext.Controller; try { //Faço a verificação apenas em produção if (ConfigurationManager.AppSettings["SECURITY_USER"].ToString().Equals("true")) { var userName = actionContext.HttpContext.Session["userId"].ToString(); //Se o usuário não tiver logado ou a sessão tiver expirado if (userName == null) { actionContext.Result = new RedirectToRouteResult( new RouteValueDictionary(new { controller = "Home", action = "Index" })); } else { HealthContext context = null; try { context = new HealthContext(); var currentUser = context.Usuarios.Where(x => x.Name == userName).FirstOrDefault(); if (currentUser != null) { if (!currentUser.IsMedical) { actionContext.Result = new RedirectToRouteResult( new RouteValueDictionary(new { controller = "Home", action = "Index" })); } } else { actionContext.Result = new RedirectToRouteResult( new RouteValueDictionary(new { controller = "Home", action = "Index" })); } context.Dispose(); } catch (Exception e) { DebugLog.Logar(e.Message); DebugLog.Logar(e.StackTrace); DebugLog.Logar(Utility.Details(e)); if (context != null) { context.Dispose(); } } } } } catch (Exception e) { DebugLog.Logar(e.Message); DebugLog.Logar(e.StackTrace); DebugLog.Logar(Utility.Details(e)); actionContext.Result = new RedirectToRouteResult( new RouteValueDictionary(new { controller = "Home", action = "Index" })); } base.OnActionExecuting(actionContext); }
public TreatmentDiseaseRepository(HealthContext context) : base(context) { }
public BranchRepository(HealthContext context) : base(context) { }
public PrescriptionRepository(HealthContext context) : base(context) { }
public DiseaseRepository(HealthContext context) : base(context) { }
public PatientsController(HealthContext context) { _context = context; }
public TemperatureRepository(HealthContext healthContext) { _healthContext = healthContext; }