Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> GetTables(string prepodname)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                string                cmd     = $"select * from TableList where ProfessorID = (select ProfessorID from ProfessorTable where EMail = N'{prepodname}')";
                SqlCommand            command = new SqlCommand(cmd, connection);
                List <ProfessorTable> tables  = new List <ProfessorTable>();

                try
                {
                    await connection.OpenAsync();

                    SqlDataReader reader = await command.ExecuteReaderAsync();

                    while (await reader.ReadAsync())
                    {
                        ProfessorTable table = new ProfessorTable();
                        table.TableName      = reader["TableName"].ToString();
                        table.SubjectName    = reader["SubjectName"].ToString();
                        table.StudentsGroups = reader["StudentsGroups"].ToString();
                        table.StudentsCourse = reader["StudentsCourse"].ToString();
                        table.UniqueCode     = reader["UniqueCode"].ToString();

                        tables.Add(table);
                    }
                    return(Request.CreateResponse(HttpStatusCode.Accepted, tables));
                }
                catch (Exception ex)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "При обработки запроса возникло исключение: " + ex.Message));
                }
            }
        }
Ejemplo n.º 2
0
        private void ProfessorTable(int i)
        {
            Random         random    = new Random();
            ProfessorTable professor = new ProfessorTable();

            using (UniversityContext context = new UniversityContext())
            {
                for (int j = 0; j < 100; j++)
                {
                    DateTime date1 = new DateTime(1950, 1, 1);
                    date1 = date1.AddYears(random.Next(0, 69));
                    date1 = date1.AddMonths(random.Next(0, 12));
                    date1 = date1.AddDays(random.Next(0, 30));
                    var prepod = Prepod();
                    professor.CathedraId     = random.Next(1, i);
                    professor.Name           = prepod.fname;
                    professor.Surname        = prepod.lname;
                    professor.Patronymic     = prepod.patronymic;
                    professor.WorkPosition   = WorkPosition();
                    professor.AcademicDegree = AcademicDegree();
                    professor.Other          = null;
                    professor.StartDate      = date1;
                    context.Professors.Add(professor);
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var student = new StudentTable();

            student.Add(new Student
            {
                FullName = "Azat Mukushev", GroupId = 1
            });

            var professor = new ProfessorTable();

            professor.Add(new Professor
            {
                FullName = "Oleg Skidan"
            });
        }