Example #1
0
        public void GivenPatientWhenRegisteringThenPersistToDb()
        {
            HospitalManagementSystemContext HospitalManagementSystemContext = EntityFrameworkMock.Create <HospitalManagementSystemContext>();

            TypeFactory.RegisterInstance(HospitalManagementSystemContext);

            Patient patient = new Patient();

            patient.PersonId         = 1;
            patient.Person.Id        = 1;
            patient.Person.FirstName = "Vusi";
            patient.Person.Surname   = "Khoza";
            patient.Person.IdNumber  = "1234";

            IPatientRepository   patientRepository   = new PatientRepository();
            IPatientRegistration patientRegistration = new PatientRegistration(patientRepository);

            patientRegistration.Register(patient);

            IPatientRetriever patientRetriever = new PatientRetriever(patientRepository);

            patientRetriever.Retrieve(patient.Person.IdNumber);

            Assert.IsNotNull(patientRetriever.Patient);
            Assert.AreEqual(patient.Person.Id, patientRetriever.Patient.Person.Id);
            Assert.AreEqual(patient.Person.FirstName, patientRetriever.Patient.Person.FirstName);
            Assert.AreEqual(patient.Person.Surname, patientRetriever.Patient.Person.Surname);
        }
Example #2
0
        /// <summary>
        /// Registers the type mappings with the Unity container.
        /// </summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>
        /// There is no need to register concrete types such as controllers or
        /// API controllers (unless you want to change the defaults), as Unity
        /// allows resolving a concrete type even if it was not previously
        /// registered.
        /// </remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below.
            // Make sure to add a Unity.Configuration to the using statements.
            // container.LoadConfiguration();
            HospitalManagementSystemContext hospitalManagementSystemContext = new HospitalManagementSystemContext();

            // TODO: Register your type's mappings here.
            // container.RegisterType<IProductRepository, ProductRepository>();
            container.RegisterType <IPatientRepository, PatientRepository>();
            container.RegisterType <IPatientRegistration, PatientRegistration>();
            container.RegisterType <IPatientRetriever, PatientRetriever>();
            container.RegisterType <IPatientsRetriever, PatientsRetriever>();

            container.RegisterType <IDoctorRepository, DoctorRepository>();
            container.RegisterType <IDoctorRegistration, DoctorRegistration>();
            container.RegisterType <IDoctorRetriever, DoctorRetriever>();
            container.RegisterType <IDoctorsRetriever, DoctorsRetriever>();

            container.RegisterType <INurseRepository, NurseRepository>();
            container.RegisterType <INurseRegistration, NurseRegistration>();
            container.RegisterType <INurseRetriever, NurseRetriever>();
            container.RegisterType <INursesRetriever, NursesRetriever>();

            container.RegisterType <IAdministratorRepository, AdministratorRepository>();
            container.RegisterType <IAdministratorRegistration, AdministratorRegistration>();
            container.RegisterType <IAdministratorRetriever, AdministratorRetriever>();
            container.RegisterType <IAdministratorsRetriever, AdministratorsRetriever>();

            container.RegisterType <IPorterRepository, PoterRepository>();
            container.RegisterType <IPorterRegistration, PorterRegistration>();
            container.RegisterType <IPorterRetriever, PorterRetriever>();
            container.RegisterType <IPortersRetriever, PortersRetriever>();

            container.RegisterInstance(hospitalManagementSystemContext);
            //TypeFactory.RegisterType<IPatientRepository,PatientRepository>();
            //TypeFactory.RegisterType<IPatientRegistration, PatientRegistration>();
            //TypeFactory.RegisterType<IPatientRetriever, PatientRetriever>();

            //TypeFactory.RegisterInstance(HospitalManagementSystemContext);
        }
 // GET: Logins
 public ActionResult Login([Bind(Include = "UserName,Password")] LoginViewModel user)
 {
     if (ModelState.IsValid)
     {
         using (HospitalManagementSystemContext db = new HospitalManagementSystemContext())
         {
             var getUserFromDatabase = db.Users.Single(x => x.UserName == user.UserName && x.Password == user.Password);
             if (getUserFromDatabase != null)
             {
                 Session["UserFound"] = user.UserName;
                 return(RedirectToAction("LoggedUser"));
             }
             else
             {
                 ViewBag.UserNotFound = user.UserName + "" + "is not registered in the system";
                 return(View(user));
             }
         }
     }
     return(View(user));
 }
Example #4
0
 // Post: Registers
 public ActionResult Register([Bind(Include = "FirstName,LastName,Email,MobileNumber,UserName,Password,")] RegisterViewModel account)
 {
     if (ModelState.IsValid)
     {
         using (HospitalManagementSystemContext db = new HospitalManagementSystemContext())
         {
             var registertedUser = db.Users.Single(x => x.Email == account.Email);
             if (registertedUser == null)
             {
                 UserAccount newUser = new UserAccount()
                 {
                     FirstName    = account.FirstName,
                     LastName     = account.LastName,
                     Email        = account.Email,
                     MobileNumber = account.MobileNumber,
                     UserName     = account.UserName,
                     Password     = account.Password
                 };
                 db.Users.Add(newUser);
                 db.SaveChanges();
                 //Redirect to login page
                 ViewBag["RegisteredUser"]        = "******" + account.FirstName + ", you are registered with Email: " + account.Email;
                 ViewBag["EmailAreadyRegistered"] = null;
                 return(RedirectToAction("Login", "Logins"));
             }
             else
             {
                 ViewBag["EmailAreadyRegistered"] = "Sorry, " + account.Email + " is already registered";
                 ViewBag["RegisteredUser"]        = null;
                 return(View(account));
             }
         }
     }
     else
     {
         return(View(account));
     }
 }
        static void Main(string[] args)
        {
            System.Console.WriteLine("Initialising Hospital Management System Data");

            HospitalManagementSystemContext hospitalManagementSystemContext = new HospitalManagementSystemContext();

            hospitalManagementSystemContext.Gender.AddRange(new List <Gender>()
            {
                new Gender()
                {
                    Id   = 1,
                    Name = "Male"
                },
                new Gender()
                {
                    Id   = 2,
                    Name = "Female"
                }
            });

            hospitalManagementSystemContext.WardType.AddRange(new List <WardType>()
            {
                new WardType()
                {
                    Id   = 1,
                    Name = "Maternity"
                },
                new WardType()
                {
                    Id   = 2,
                    Name = "Pediatrics"
                },
                new WardType()
                {
                    Id   = 3,
                    Name = "Psychiatric"
                },
                new WardType()
                {
                    Id   = 4,
                    Name = "Intensive Care Unit"
                }
            });

            hospitalManagementSystemContext.Ward.AddRange(new List <Ward>()
            {
                new Ward()
                {
                    Id          = 1,
                    Number      = "WD001",
                    WardTypeId  = 1,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Ward()
                {
                    Id          = 2,
                    Number      = "WD002",
                    WardTypeId  = 4,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Ward()
                {
                    Id          = 3,
                    Number      = "WD003",
                    WardTypeId  = 3,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Ward()
                {
                    Id          = 4,
                    Number      = "WD004",
                    WardTypeId  = 2,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                }
            });

            hospitalManagementSystemContext.Bed.AddRange(new List <Bed>()
            {
                new Bed()
                {
                    Number      = "BD001",
                    WardId      = 1,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD002",
                    WardId      = 1,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD003",
                    WardId      = 2,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD004",
                    WardId      = 2,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD005",
                    WardId      = 3,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD006",
                    WardId      = 3,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD007",
                    WardId      = 4,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                },
                new Bed()
                {
                    Number      = "BD008",
                    WardId      = 4,
                    CreatedById = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                }
            });

            hospitalManagementSystemContext.Nationality.AddRange(new List <Nationality>()
            {
                new Nationality()
                {
                    Id   = 1,
                    Name = "South Africa"
                },
                new Nationality()
                {
                    Id   = 2,
                    Name = "Lesotho"
                },
                new Nationality()
                {
                    Id   = 3,
                    Name = "Zimbabwe"
                },
                new Nationality()
                {
                    Id   = 4,
                    Name = "Angola"
                }
            });

            hospitalManagementSystemContext.DoctorType.AddRange(new List <DoctorType>()
            {
                new DoctorType()
                {
                    Id   = 1,
                    Name = "Anesthesiologist"
                },
                new DoctorType()
                {
                    Id   = 2,
                    Name = "Immunologist"
                },
                new DoctorType()
                {
                    Id   = 3,
                    Name = "Medicine Specialist"
                },
                new DoctorType()
                {
                    Id   = 4,
                    Name = "Psychiatrist"
                },
                new DoctorType()
                {
                    Id   = 5,
                    Name = "Cardiologist"
                },
                new DoctorType()

                {
                    Id   = 6,
                    Name = "Cardiovascular Surgeon"
                }
            });
            hospitalManagementSystemContext.Race.AddRange(new List <Race>()
            {
                new Race()
                {
                    Id   = 1,
                    Name = "Black"
                },
                new Race()
                {
                    Id   = 2,
                    Name = "White"
                },
                new Race()
                {
                    Id   = 3,
                    Name = "Indian"
                },
                new Race()
                {
                    Id   = 4,
                    Name = "Asian"
                },
                new Race()
                {
                    Id   = 5,
                    Name = "hawaiian"
                },
                new Race()

                {
                    Id   = 6,
                    Name = "Alaska Native"
                }
            });
            hospitalManagementSystemContext.Province.AddRange(new List <Province>()
            {
                new Province()
                {
                    Id   = 1,
                    Name = "Western Cape"
                },
                new Province()
                {
                    Id   = 2,
                    Name = "Eastern Cape"
                },
                new Province()
                {
                    Id   = 3,
                    Name = "Northern Cape"
                },
                new Province()
                {
                    Id   = 4,
                    Name = "North West"
                },
                new Province()
                {
                    Id   = 5,
                    Name = "Free State"
                },
                new Province()

                {
                    Id   = 6,
                    Name = "Kwazulu Natal"
                },
                new Province()
                {
                    Id   = 7,
                    Name = "Gauten"
                },
                new Province()
                {
                    Id   = 8,
                    Name = "Limpopo"
                },
                new Province()
                {
                    Id   = 9,
                    Name = "Mpumalanga"
                }
            });

            //hospitalManagementSystemContext.Patient.AddRange(new List<Patient>()
            //{
            //   new Patient()
            //   {

            //   }
            //});


            hospitalManagementSystemContext.SaveChanges();

            System.Console.WriteLine("Hospital Management System Data Inserted");
            System.Console.ReadKey();
        }