public async Task <List <MinRoomDetailsDto> > GetRoomsDateAndSessionWise(string date, string session) { List <MinRoomDetailsDto> Rooms = new List <MinRoomDetailsDto>(); using (var command = _context.Database.GetDbConnection().CreateCommand()) { command.CommandText = $@"select RoomId,RoomNumber,Date,Session from roomexams join rooms r on roomexams.RoomId = r.Id join exams e on roomexams.ExamId = e.Id AND Date='{date}' AND Session='{session}' group by RoomNumber;"; Console.WriteLine("3"); command.CommandType = CommandType.Text; await _context.Database.OpenConnectionAsync(); using (var result = await command.ExecuteReaderAsync()) { while (await result.ReadAsync()) { MinRoomDetailsDto minRoomDetailsDto = new MinRoomDetailsDto() { Id = result.GetInt32(0), RoomName = result.GetString(1) }; Rooms.Add(minRoomDetailsDto); } } } return(Rooms); }
public async Task <IEnumerable> GetRooms() { List <MinRoomDetailsDto> Rooms = new List <MinRoomDetailsDto>(); using (var command = _context.Database.GetDbConnection().CreateCommand()) { command.CommandText = @"select Id,RoomNumber from rooms group by RoomNumber;"; command.CommandType = CommandType.Text; await _context.Database.OpenConnectionAsync(); using (var result = await command.ExecuteReaderAsync()) { while (await result.ReadAsync()) { MinRoomDetailsDto minRoomDetailsDto = new MinRoomDetailsDto() { Id = result.GetInt32(0), RoomName = result.GetString(1) }; Rooms.Add(minRoomDetailsDto); } } } return(Rooms); }
public async Task <IActionResult> UpdateRooms(MinRoomDetailsDto minRoomDetailsDto) { try { await _seatingRepository.UpdateRoom(minRoomDetailsDto); return(Ok(new { res = "Success !!!" })); } catch (Exception e) { Console.WriteLine(e); return(BadRequest(new { res = "Error Occured" })); } }
public async Task UpdateRoom(MinRoomDetailsDto minRoomDetailsDto) { var room = await _context.Rooms.FirstOrDefaultAsync(x => x.Id == minRoomDetailsDto.Id); await _context.Database.ExecuteSqlInterpolatedAsync($"UPDATE rooms set RoomNumber={minRoomDetailsDto.RoomName} where RoomNumber={room.RoomNumber};"); }