Ejemplo n.º 1
0
        public static bool AuthenticateDoctor(Credential credent, HttpSessionStateBase session)
        {
            session["LoggedIn"] = false;
            session["IsAdmin"]  = false;

            Doctor doc = DoctorPersistence.GetDoctorByID(credent.DoctorID);

            if (doc == null)
            {
                return(false);
            }

            if (doc.DoctorID == null)
            {
                return(false);
            }

            else
            {
                string HashedPassword = EncryptionManager.EncodePassword(credent.Password, doc.Salt);

                if (HashedPassword == doc.HashedPassword)
                {
                    session["LoggedIn"] = true;
                    session["IsAdmin"]  = doc.IsAdmin;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 2
0
        public void Map_doctor_persistance_to_doctor_entity_when_persistance_is_null()
        {
            DoctorPersistence doctorPersistance = null;

            Assert.Throws <ArgumentNullException>(()
                                                  => DoctorMapper.MapDoctorPersistenceToDoctorEntity(doctorPersistance));
        }
Ejemplo n.º 3
0
        public void Map_doctor_persistence_to_doctor_entity()
        {
            DoctorPersistence doctorPersistance = this.GetDoctorPersistanceFirst();

            Doctor doctorEntity = DoctorMapper.MapDoctorPersistenceToDoctorEntity(doctorPersistance);

            Assert.True(this.IsEqualDoctorPersistanceAndDoctorEntity(doctorPersistance, doctorEntity));
        }
Ejemplo n.º 4
0
        /*
         * Transaction: Delete a doctor from the database
         * Returns true iff the doctor exists in the database and
         * it was successfully deleted.
         */
        public static bool DeleteDoctor(Doctor delDoctor)
        {
            Doctor checkDoctor = DoctorPersistence.GetDoctor(delDoctor);

            if (checkDoctor == null)
            {
                return(false);
            }
            return(DoctorPersistence.DeleteDoctor(delDoctor));
        }
Ejemplo n.º 5
0
        /*
         * Transaction: Update a doctor in the database
         * Returns true iff the doctor exists in the database and
         * it was successfully changed.
         */
        public static bool ChangeDoctor(Doctor changeDoctor)
        {
            Doctor checkDoctor = DoctorPersistence.GetDoctor(changeDoctor);

            if (checkDoctor == null)
            {
                return(false);
            }

            return(DoctorPersistence.ChangeDoctor(changeDoctor));
        }
Ejemplo n.º 6
0
        public static Doctor[] GetAllDoctors()
        {
            List <Doctor> doctors = DoctorPersistence.GetAllDoctors();

            if (doctors != null)
            {
                return(DoctorPersistence.GetAllDoctors().ToArray());
            }
            else
            {
                return(new Doctor[0]);
            }
        }
Ejemplo n.º 7
0
 public static Doctor MapDoctorPersistenceToDoctorEntity(DoctorPersistence doctorPersistence)
 => doctorPersistence == null ? throw new ArgumentNullException()
                                 : new Doctor()
 {
     Id               = doctorPersistence.Id,
     Name             = doctorPersistence.Name,
     Surname          = doctorPersistence.Surname,
     Username         = doctorPersistence.Username,
     Password         = doctorPersistence.Password,
     Jmbg             = doctorPersistence.Jmbg,
     Biography        = doctorPersistence.Biography,
     SpecializationId = doctorPersistence.SpecializationId
 };
Ejemplo n.º 8
0
        /*
         * Transaction: Add a new doctor to the database
         * Returns true iff the new doctor has a unique ISBN
         * and it was successfully added.
         */
        public static bool AddNewDoctor(Doctor newDoctor)
        {
            // Verify that the doctor doesn't already exist
            Doctor oldDoctor = DoctorPersistence.GetDoctor(newDoctor);

            // oldDoctor should be null, if this is a new doctor
            if (oldDoctor != null)
            {
                return(false);
            }


            return(DoctorPersistence.AddDoctor(newDoctor));
        }
Ejemplo n.º 9
0
        private bool IsEqualDoctorPersistanceAndDoctorEntity(DoctorPersistence doctorPersistence, Doctor doctor)
        {
            if (doctorPersistence.Id != doctor.Id)
            {
                return(false);
            }

            if (!doctorPersistence.Jmbg.Equals(doctor.Jmbg))
            {
                return(false);
            }

            if (!doctorPersistence.Username.Equals(doctor.Username))
            {
                return(false);
            }

            if (!doctorPersistence.Password.Equals(doctor.Password))
            {
                return(false);
            }

            if (!doctorPersistence.Name.Equals(doctor.Name))
            {
                return(false);
            }

            if (!doctorPersistence.Surname.Equals(doctor.Surname))
            {
                return(false);
            }

            if (doctorPersistence.SpecializationId != doctor.SpecializationId)
            {
                return(false);
            }


            return(true);
        }