Exemplo n.º 1
0
        public StaffListResponse GetStaffList()
        {
            StaffListResponse model = new StaffListResponse();

            if (connection == null || SQLConnectionController.ConnectionState != ConnectionStateEnum.CONNECTED)
            {
                throw new ArgumentNullException();
            }
            command.CommandText = "USE DB_A5D903_humanDeptDB " +
                                  "SELECT [id], [secondname] FROM dbo.Employee";
            model.StaffList = new List <StaffModelRequest>();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                model.StaffList.Add(new StaffModelRequest()
                {
                    Id   = (int)reader.GetValue(0),
                    Name = (string)reader.GetValue(1)
                });
            }
            reader.Close();
            return(model);
        }
Exemplo n.º 2
0
        public JsonResult LoadStaffList()
        {
            StaffListResponse response = _employeeRepository.GetStaffList();

            return(Json(response));
        }