示例#1
0
        public DoctorsViewModel UpdateDoctors(int _id_doctor, DoctorsViewModel _doctor)
        {
            DoctorsEntity upd_doctor = new DoctorsEntity();

            upd_doctor.Person.Name     = _doctor.Name;
            upd_doctor.Person.Surname  = _doctor.Surname;
            upd_doctor.Person.Address  = _doctor.Address;
            upd_doctor.Person.Phone    = _doctor.Phone;
            upd_doctor.Department.Name = _doctor.Department;

            new DoctorsRepository().Update(_id_doctor, upd_doctor);

            return(this.ReadOneDoctor(_id_doctor));
        }
示例#2
0
        //---------------------------------------------------------------------
        public DoctorsEntity Insert(DoctorsEntity _doctor)
        {
            string _procedure = "CRT_Doctors";

            var(_connection, _command, _transaction) = new ConnectionManager().CreateConnection(_procedure);
            _command.Parameters.Add(new SqlParameter("@_name", _doctor.Person.Name));
            _command.Parameters.Add(new SqlParameter("@_surname", _doctor.Person.Surname));
            _command.Parameters.Add(new SqlParameter("@_address", _doctor.Person.Address));
            _command.Parameters.Add(new SqlParameter("@_phone", _doctor.Person.Phone));
            _command.Parameters.Add(new SqlParameter("@_depname", _doctor.Department.Name));

            new ConnectionManager().ExecuteNonQuery(_connection, _command, _transaction);
            return(_doctor);
        }
示例#3
0
        public DoctorsViewModel InsertDoctors(DoctorsViewModel _doctor)
        {
            DoctorsEntity new_doctor = new DoctorsEntity();

            new_doctor.Person          = new PersonsEntity();
            new_doctor.Person.Name     = _doctor.Name;
            new_doctor.Person.Surname  = _doctor.Surname;
            new_doctor.Person.Address  = _doctor.Address;
            new_doctor.Person.Phone    = _doctor.Phone;
            new_doctor.Department      = new DepartmentsEntity();
            new_doctor.Department.Name = _doctor.Department;

            new DoctorsRepository().Insert(new_doctor);

            return(this.ReadOneDoctor(0));
        }
示例#4
0
        //---------------------------------------------------------------------
        public DoctorsEntity ReadOne(int _id_doctor)
        {
            DoctorsEntity doctor     = new DoctorsEntity();
            const string  _procedure = "READ_Doctors_one";

            var(_connection, _command, _transaction) = new ConnectionManager().CreateConnection(_procedure);
            _command.Parameters.Add(new SqlParameter("@_id_doctor", _id_doctor));

            using (_connection)
            {
                try
                {
                    using (SqlDataReader _dataReader = _command.ExecuteReader())
                    {
                        while (_dataReader.Read())
                        {
                            DoctorsEntity _doctor = new DoctorsEntity
                            {
                                Id           = _dataReader.GetInt32("id"),
                                Removed      = _dataReader.GetBoolean("removed"),
                                IdPerson     = _dataReader.GetInt32("id_person"),
                                IdDepartment = _dataReader.GetInt32("id_department"),
                            };
                            _doctor.Person      = new PersonsRepository().ReadOne(_doctor.IdPerson);
                            _doctor.Department  = new DepartmentsRepository().ReadOne(_doctor.IdDepartment);
                            _doctor.Specialties =
                                new SpecialtiesRepository().ReadAllForDoctor(_doctor.Id);

                            doctor = _doctor;
                        }
                        _dataReader.Close();
                        ////_transaction.Commit();
                    }
                }
                catch (Exception ex)
                {
                    Debug.Write(ex.Message);
                    ////_transaction.Rollback();
                }
            }
            return(doctor);
        }