Ejemplo n.º 1
0
        public async Task <IEnumerable> AllExamDates()
        {
            List <MinExamDto> examDtos = new List <MinExamDto>();

            using (var command = _context.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = "select id, date from exams group by date;";

                command.CommandType = CommandType.Text;

                await _context.Database.OpenConnectionAsync();

                using (var result = await command.ExecuteReaderAsync())
                {
                    while (await result.ReadAsync())
                    {
                        MinExamDto minExamDto = new MinExamDto()
                        {
                            Id   = result.GetInt32(0),
                            Date = result.GetString(1)
                        };

                        examDtos.Add(minExamDto);
                    }
                    return(examDtos);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <List <MinExamDto> > GetExamDateswithSession()
        {
            List <MinExamDto> examList = new List <MinExamDto>();

            using (var command = _context.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = "SELECT id,date,session from exams group by date,session;";
                command.CommandType = CommandType.Text;

                await _context.Database.OpenConnectionAsync();

                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        MinExamDto minExamDto = new MinExamDto()
                        {
                            Id      = reader.GetInt32(0),
                            Date    = reader.GetString(1),
                            Session = reader.GetString(2)
                        };
                        examList.Add(minExamDto);
                    }
                }
            }
            return(examList);
        }
Ejemplo n.º 3
0
        public async Task UpdateExamDate(MinExamDto minExamDto)
        {
            Console.WriteLine($"{minExamDto.Id}   {minExamDto.Date}");
            var data = await _context.Exams.FirstOrDefaultAsync(x => x.Id == minExamDto.Id);

            await _context.Database.ExecuteSqlInterpolatedAsync($"update exams set Date={minExamDto.Date} where Date={data.Date};");

            await _context.Database.ExecuteSqlInterpolatedAsync($"update semester set Date={minExamDto.Date} where  Date={data.Date};");
        }
        public async Task <IActionResult> UpdateExams(MinExamDto minExamDto)
        {
            try
            {
                await _seatingRepository.UpdateExamDate(minExamDto);

                return(Ok(new { res = "Success !!!" }));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(BadRequest(new { res = "Error Occured" }));
            }
        }