Example #1
0
        public void Update(Doctor item)
        {
            var doctorEntity = new DoctorEntity();

            doctorMapper.MapToEntity(item, doctorEntity);
            doctorRepository.Update(doctorEntity);
        }
        private bool AdditionOfParameters(DoctorEntity tempObject, string Command)
        {
            SqlCommand command = new SqlCommand(Command);

            SqlParameter UserNameParameter = new SqlParameter("@dUserName", SqlDbType.NVarChar, 50);

            UserNameParameter.Value = tempObject.doctorUserName;
            SqlParameter PasswordParameter = new SqlParameter("@dPassword", SqlDbType.NVarChar, 50);

            PasswordParameter.Value = tempObject.doctorPassword;
            SqlParameter NameParameter = new SqlParameter("@dName", SqlDbType.NVarChar, 100);

            NameParameter.Value = tempObject.doctorName;
            SqlParameter DoctorSpecialityParameter = new SqlParameter("@dSpeciality", SqlDbType.NVarChar, 50);

            DoctorSpecialityParameter.Value = tempObject.doctorSpeciality;

            //Adding parameters
            command.Parameters.Add(UserNameParameter);
            command.Parameters.Add(PasswordParameter);
            command.Parameters.Add(NameParameter);
            command.Parameters.Add(DoctorSpecialityParameter);

            if (ObjectOfDataAccess.ExecuteCommand(command) == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 // Method used for doctors when he successfully logged in, store its connection id for usage
 public void Connect(int doctorUserId)
 {
     try
     {
         DoctorEntity doctorEntity = _docTalkDBContext.DoctorEntities.FirstOrDefault(x => x.UserId == doctorUserId);
         if (doctorEntity != null)
         {
             doctorEntity.DoctorConnectionId = Context.ConnectionId;
         }
         else
         {
             DoctorEntity doctorEntities = new DoctorEntity()
             {
                 DoctorConnectionId = Context.ConnectionId,
                 UserId             = doctorUserId
             };
             _docTalkDBContext.DoctorEntities.Add(doctorEntities);
         }
         _docTalkDBContext.SaveChanges();
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
        public MainMDIForm(DoctorEntity doctor)
        {
            InitializeComponent();

            _de = doctor;
            initDoctorEntity();
        }
Example #5
0
        /// <summary>
        /// Get a doctor by given id
        /// </summary>
        /// <returns></returns>
        public DoctorEntity GetDoctorById(int doctorId)
        {
            Doctor daDoctor = _dataAccessService.DoctorRepository.GetItemById(doctorId);

            if (daDoctor == null)
            {
                return(null);
            }

            DoctorEntity doctor = new DoctorEntity
            {
                Id        = doctorId,
                FirstName = daDoctor.FirstName,
                LastName  = daDoctor.LastName,
                Roles     = (from r in _dataAccessService.DoctorRoleRepository.GetAllItems()
                             from x in _dataAccessService.DoctorRoleXrefRepository.GetAllItems()
                             where r.Id == x.DoctorRoleID && x.DoctorID == doctorId
                             select new DoctorRoleEntity {
                    Id = r.Id, DoctorRoleName = r.DoctorRoleName
                }
                             ).ToList()
            };

            return(doctor);
        }
Example #6
0
 public void UpdateDoctorsName(DoctorEntity doctor)
 {
     CreateSqlCommandSP("UpdateDoctorsName");
     AddParameterInt("@id", doctor.id);
     AddParameterString("@name", doctor.name);
     dataReader = ExecuteReader();
 }
Example #7
0
        public void Remove(Doctor item)
        {
            DoctorEntity entity = new DoctorEntity();

            doctorMapper.MapToEntity(item, entity);
            repository.Delete(entity);
        }
Example #8
0
        public DoctorEntity GetDoctorById(int doctorId)
        {
            try
            {
                DoctorEntity doctor = new DoctorEntity();

                CreateSqlCommandSP("GetDoctorById");
                AddParameterInt("@id", doctorId);
                dataReader = ExecuteReader();
                if (dataReader.Read())
                {
                    doctor.id           = dataReader.GetInt32(0);
                    doctor.idOrdination = dataReader.GetInt32(1);
                    doctor.name         = dataReader.GetString(2);
                    doctor.lastName     = dataReader.GetString(3);
                }
                return(doctor);
            }
            catch (Exception exc)
            {
                throw exc;
            }
            finally
            {
                CloseConnection();
            }

            return(null);
        }
Example #9
0
        public void Add(Doctor item)
        {
            DoctorEntity entity = new DoctorEntity();

            doctorMapper.MapToEntity(item, entity);
            repository.Create(entity);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            DoctorEntity doctorEntity = await db.Doctors.FindAsync(id);

            db.People.Remove(doctorEntity);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #11
0
        public void InsertIntoDoctor(DoctorEntity doctor)
        {
            CreateSqlCommandSP("InsertIntoDoctor");

            AddParameterString("@name", doctor.name);
            AddParameterString("@lastName", doctor.lastName);
            AddParameterInt("@idOrdination", doctor.idOrdination);
            dataReader = ExecuteReader();
        }
Example #12
0
        public void Task_Doctor_showData_Selective_NotPresent()
        {
            //Arrange
            List <DoctorEntity> db = InitialSeed.doctorSeed();

            //Act
            DoctorEntity db1 = DAL.showData(db, 2);

            //Assert
            Assert.NotEqual(db1, db[0]);
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,FirstName,LastName,Age,Email,Password,Information,Location")] DoctorEntity doctorEntity)
        {
            if (ModelState.IsValid)
            {
                db.Entry(doctorEntity).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(doctorEntity));
        }
        public static DoctorEntity doctorSeed2()
        {
            DoctorEntity de1 = new DoctorEntity();

            de1.dId                  = 2;
            de1.doctorType           = "Dentist";
            de1.personEntity.name    = "Amita";
            de1.personEntity.address = "Bch";
            de1.personEntity.email   = "*****@*****.**";
            de1.personEntity.gender  = "F";
            return(de1);
        }
Example #15
0
        public void Task_Doctor_insertData()
        {
            //Arrange
            List <DoctorEntity> db  = InitialSeed.doctorSeed();
            List <DoctorEntity> db1 = InitialSeed.doctorSeed1();
            DoctorEntity        de  = InitialSeed.doctorSeed2();

            //Act
            List <DoctorEntity> db2 = DAL.insertData(db, de);

            //Assert
            Assert.NotEqual(db1, db2);
        }
Example #16
0
        public void SaveDoctor(DoctorEntity entity)
        {
            if (entity.Id == 0)
            {
                _context.Add(entity);
            }
            else
            {
                _context.Update(entity);
            }

            _context.SaveChanges();
        }
        // GET: DoctorEntities/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DoctorEntity doctorEntity = await db.Doctors.FindAsync(id);

            if (doctorEntity == null)
            {
                return(HttpNotFound());
            }
            return(View(doctorEntity));
        }
        public static List <DoctorEntity> doctorSeed()
        {
            List <DoctorEntity> db = new List <DoctorEntity>();
            DoctorEntity        de = new DoctorEntity();

            de.dId                  = 1;
            de.doctorType           = "Cardiac";
            de.personEntity.name    = "Ashif";
            de.personEntity.address = "Abc";
            de.personEntity.email   = "*****@*****.**";
            de.personEntity.gender  = "M";
            db.Add(de);
            return(db);
        }
Example #19
0
        public DataTable ToCheckLoginCredentials(DoctorEntity tempObject)
        {
            string checkCommand = "SELECT * FROM doctor WHERE dUserName = @dUserName AND dPassword = @dPassword";

            SqlCommand command = new SqlCommand(checkCommand);

            SqlParameter UserNameParameter = new SqlParameter("@dUserName", SqlDbType.NVarChar, 50);

            UserNameParameter.Value = tempObject.doctorUserName;
            SqlParameter PasswordParameter = new SqlParameter("@dPassword", SqlDbType.NVarChar, 50);

            PasswordParameter.Value = tempObject.doctorPassword;

            //Adding command
            command.Parameters.Add(UserNameParameter);
            command.Parameters.Add(PasswordParameter);

            var d = ObjectOfDataAccess.Query(command);

            if (d.Rows.Count == 1)
            {
                //Login Success
                //string userName = d.Rows[0][2].ToString();

                /*(List<DoctorEntity> doctor = new List<DoctorEntity>();
                 * for (int i = 0; i < d.Rows.Count; i++)
                 * {
                 *  DoctorEntity _de = new DoctorEntity();
                 *
                 *  _de.doctorUserName = d.Rows[i][0].ToString();
                 *  _de.doctorPassword = d.Rows[i][1].ToString();
                 *  _de.doctorName = d.Rows[i][2].ToString();
                 *  _de.doctorSpeciality = d.Rows[i][3].ToString();
                 *
                 *  doctor.Add(_de);
                 * }
                 *
                 * //return userName;
                 *
                 * return doctor;*/

                return(d);
            }

            else
            {
                return(null);
            }
        }
Example #20
0
 public void ReleaseDoctor(string contextId)
 {
     try
     {
         DoctorEntity doctorContext = _docTalkDBContext.DoctorEntities.FirstOrDefault(x => x.DoctorConnectionId == contextId);
         if (doctorContext != null)
         {
             doctorContext.DoctorConnectionId = "";
             Doctor doctor = doctorContext.Doctor;
             doctor.IsLocked = false;
             _docTalkDBContext.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #21
0
        public List <DoctorEntity> GetAllDoctors()
        {
            CreateSqlCommandSP("GetAllDoctors");
            dataReader = ExecuteReader();
            List <DoctorEntity> listDoctors = new List <DoctorEntity>();

            while (dataReader.Read())
            {
                DoctorEntity doctor = new DoctorEntity();
                doctor.id           = dataReader.GetInt32(0);
                doctor.idOrdination = dataReader.GetInt32(1);
                doctor.name         = dataReader.GetString(2);
                doctor.lastName     = dataReader.GetString(3);

                listDoctors.Add(doctor);
            }

            return(listDoctors);
        }
Example #22
0
        public async Task JoinRoom()
        {
            try
            {
                string roomName       = Guid.NewGuid().ToString();
                Doctor avilableDoctor = GetAvailableDoctor();
                if (avilableDoctor != null)
                {
                    LockDoctor(avilableDoctor);
                    DoctorEntity assignUserContext = avilableDoctor.DoctorEntities.FirstOrDefault();
                    if (assignUserContext != null)
                    {
                        AddRoom(roomName, assignUserContext.DoctorConnectionId, Context.ConnectionId);
                        await Groups.Add(Context.ConnectionId, roomName);

                        await Groups.Add(assignUserContext.DoctorConnectionId, roomName);

                        Message message = new Message()
                        {
                            groupName = roomName,
                            message   = "joined to Room"
                        };
                        await Clients.Group(roomName).addChatMessage(message, "GroupCreated");
                    }
                }
                else
                {
                    Message message = new Message()
                    {
                        groupName = roomName,
                        message   = "No Doctor is available to create room"
                    };
                    await Clients.Group(roomName).SendAsync("No Doctor is available to Join room");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #23
0
        public static DoctorEntity LoadDoctorById(int doctorId, int hospitalId)
        {
            DoctorEntity doctor = null;

            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                doctor = (from d in data.Doctors
                          from dh in d.Doctor_Hospitals
                          where d.Doctor_ID == doctorId &&
                          dh.Hospital_ID == hospitalId
                          select new DoctorEntity()
                {
                    Doctor_ID = d.Doctor_ID,
                    First_Name = d.First_Name,
                    Last_Name = d.Last_Name,
                    Gender = d.Gender,
                    Degree = d.Degree,
                    Experience = d.Experience,
                    Working_Day = d.Working_Day
                }).SingleOrDefault();
                if (doctor != null)
                {
                    List <Speciality> specialities = null;
                    Photo             photo        = new Photo();

                    specialities = (from d in data.Doctors
                                    from ds in d.Doctor_Specialities
                                    where doctor.Doctor_ID == d.Doctor_ID
                                    select ds.Speciality).ToList <Speciality>();
                    photo = (from p in data.Photos
                             where doctor.Doctor_ID == p.Doctor_ID
                             select p).SingleOrDefault();

                    doctor.Specialities = specialities;
                    doctor.Photo        = photo;
                }
            }
            return(doctor);
        }