public async static Task <IActionResult> GetRoomsBySemesterId(RoomDBContext context, int semesterId) { try { var response = new List <RoomResponse>(); var listRoom = RoomDAO.GetRoomBySemester(context, semesterId); foreach (var room in listRoom) { response.Add(new RoomResponse { RoomId = room.RoomId, RoomName = room.Subject + "-" + room.ClassName, TeacherId = room.CreatorId, Image = room.Image, SemesterId = (int)room.SemesterId }); } return(new OkObjectResult(response)); } catch (Exception e) { return(new ObjectResult(new { message = e.Message }) { StatusCode = 500, }); } }
public async static Task <IActionResult> DeleteRoom(RoomDBContext context, int roomId, IWebHostEnvironment env) { var room = RoomDAO.Get(context, roomId); if (room != null) { var roomUserLinks = RoomUserLinkDAO.GetRoomLink(context, roomId); var roomChats = RoomChatDAO.GetChatByRoomId(context, roomId); var roomTimetables = TimetableDAO.GetByRoomId(context, roomId); var groups = RoomDAO.GetGroupByRoom(context, roomId); var result = await RoomUserLinkDAO.Delete(context, roomUserLinks); result = await RoomChatDAO.DeleteRoomChat(context, roomChats); result = await TimetableDAO.DeleteTimeTable(context, roomTimetables); foreach (var group in groups) { result = await DeleteRoom(context, group.RoomId, env); } var path = Path.Combine(env.ContentRootPath, $"Files/{roomId}"); if (Directory.Exists(path)) { Directory.Delete(path, true); } result = await RoomDAO.Delete(context, room); return(result); } return(new BadRequestObjectResult(new { message = "Class now exist!" })); }
public async Task DeleteFail(int roomId1, int roomId2) { var room = new Room() { RoomId = roomId1, Subject = "testSubject", ClassName = "testName", CreatorId = "testUser", SemesterId = 1 }; var room2 = new Room() { RoomId = roomId2, Subject = "testSubject", ClassName = "testName", CreatorId = "testUser", SemesterId = 1 }; // Act var result = await RoomDAO.Create(roomContext, room); // Assert Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); result = await RoomDAO.Delete(roomContext, room2); Assert.Equal((int)HttpStatusCode.InternalServerError, ((ObjectResult)result).StatusCode); room = RoomDAO.Get(roomContext, roomId1); Assert.NotNull(room); }
public RoomServiceTest() { //setting up context factory = new ConnectionFactory(); _context = factory.CreateRoomDbContextForInMemory(); _context.Database.EnsureDeleted(); _context.Database.EnsureCreated(); _context.SaveChanges(); var room = new Room() { RoomId = 1, Subject = "testSubject", ClassName = "testName", CreatorId = "testUser", SemesterId = 1 }; RoomDAO.Create(_context, room); var chats = new List <RoomChat>(); chats.Add(new RoomChat() { Id = 1, RoomId = 1, UserId = "testUser", Date = DateTime.Now, Content = "testChat", Type = 1, }); chats.Add(new RoomChat() { Id = 2, RoomId = 1, UserId = "testUser", Date = DateTime.Now, Content = "testChat", Type = 1, }); chats.Add(new RoomChat() { Id = 3, RoomId = 1, UserId = "testUser", Date = DateTime.Now, Content = "testChat", Type = 1, }); foreach (var chat in chats) { RoomChatDAO.Create(_context, chat); } var links = new List <RoomUserLink>(); links.Add(new RoomUserLink() { RoomId = 1, RoomUserId = 1, UserId = "testUser" }); links.Add(new RoomUserLink() { RoomId = 1, RoomUserId = 2, UserId = "testUser1" }); links.Add(new RoomUserLink() { RoomId = 1, RoomUserId = 3, UserId = "testUser2" }); RoomUserLinkDAO.Create(_context, links); _env = new Mock <IWebHostEnvironment>(); _env.Setup(f => f.ContentRootPath).Returns(""); }
public async Task RoomUpdateSuccessfully(int roomId) { //Arrange var room = new Room() { RoomId = roomId, Subject = "testSubject", ClassName = "testName", CreatorId = "testUser", SemesterId = 1 }; // Act var result = await RoomDAO.Create(roomContext, room); // Assert Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); room.Subject = "testSubject2"; room.ClassName = "testName2"; result = RoomDAO.UpdateRoom(roomContext, room); var resultRoom = RoomDAO.Get(roomContext, roomId); Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); Assert.Equal(resultRoom.RoomId, room.RoomId); Assert.Equal(resultRoom.Subject, room.Subject); Assert.Equal(resultRoom.ClassName, room.ClassName); Assert.Equal(resultRoom.CreatorId, room.CreatorId); Assert.Equal(resultRoom.SemesterId, room.SemesterId); }
private void LoadGridData() { List <Room> rooms = RoomDAO.GetRoomBedPricesByRoomName(cbxRoom.SelectedValue.ToString()); dataGridViewRoom.DataSource = rooms; lblNotify.Visible = true; }
public async void UpdateClassSuccessful() { var model = new ClassRequest() { @class = "testName1", subject = "testSubject1", teacher = "testUser", students = new List <string> { "testUser1", "TestUser2", "TestUser3" } }; var result = await _SemetserService.Object.AddClass(1, model); Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); var models = new List <ClassRequest>(); models.Add(new ClassRequest() { id = "2", @class = "testName2", subject = "testSubject3", teacher = "testUser", students = new List <string> { "testUser1", "TestUser2", "TestUser3" } }); result = await _SemetserService.Object.UpdateClass(1, models); Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); var response = RoomDAO.Get(roomContext, 2); Assert.Equal(response.ClassName, "testName2"); Assert.Equal(response.Subject, "testSubject3"); }
public ManagerBookRequestGUI(string user) { InitializeComponent(); List <String> list = new List <string>(); list.Add("In progess"); list.Add("Accepted"); list.Add("Rejected"); comboBoxStatus.DataSource = list; DataTable dt = RoomDAO.GetDataTableRoomGroupBy(); comboBoxRoom.DataSource = dt; comboBoxRoom.DisplayMember = "roomName"; comboBoxRoom.ValueMember = "roomName"; DataTable dt1 = RoomDAO.GetDataTableBedNoStatus(comboBoxRoom.SelectedValue.ToString()); comboBoxBedNo.DataSource = dt1; comboBoxBedNo.ValueMember = "bedNo"; comboBoxBedNo.DisplayMember = "bedNo"; view(); btnAccept.Enabled = true; btnDecline.Enabled = true; }
public static GroupResponse GroupUpdate(RoomDBContext context, HttpRequest request) { var groupId = Convert.ToInt32(request.Form["groupId"]); var listUserIds = (IEnumerable <string>)JsonConvert.DeserializeObject <List <string> >(request.Form["userIds"]); var existLinks = (IEnumerable <string>)context.RoomUserLink.Where(link => link.RoomId == groupId).Select(link => link.UserId).ToList(); var group = RoomDAO.Get(context, groupId); if (group != null) { var deleteUserIds = existLinks.Except(listUserIds).ToList(); var addUserIds = listUserIds.Except(existLinks).ToList(); var deleteLinks = deleteUserIds.Select(item => RoomUserLinkDAO.GetRoomUserLink(context, groupId, item)).ToList(); var addLinks = addUserIds.Select(item => new RoomUserLink { UserId = item, RoomId = group.RoomId }).ToList(); var result = RoomUserLinkDAO.Create(context, addLinks); result = RoomUserLinkDAO.Delete(context, deleteLinks); return(new GroupResponse { GroupId = group.RoomId, Name = group.Subject, UserIds = RoomUserLinkDAO.GetRoomLink(context, group.RoomId).Select(item => item.UserId).ToList(), StartTime = group.StartDate.ToUniversalTime(), EndTime = group.EndDate.ToUniversalTime() }); } return(null); }
void loadAllRoom() { var dao = new RoomDAO(); var listRoom = dao.listRoom(); loadRoom(listRoom); }
public static Room MapToRoomDAO(RoomDAO room) { var r = new Room(); r.RoomID = room.Id; r.RoomNumber = room.RoomNumber; return(r); }
public static RoomDAO MapToRoomDAO(Room room) { var r = new RoomDAO(); r.Id = room.RoomID; r.RoomNumber = room.RoomNumber.Value; return(r); }
public static bool UpdateRoom(RoomDTO room) { if (RoomDAO.CheckRentedRoomByID(room.RoomID)) { return(false); } return(RoomDAO.UpdateRoom(room)); }
public bool InsertRoom(RoomDAO room) { var r = new Room(); r.RoomNum = room.RoomNumber; return(ef.AddRoom(r)); }
private async void Refresh() { IsBusy = true; await RoomDAO.GetRoomsForMove(_moveId); onPropertyChanged(nameof(Rooms)); IsBusy = false; }
public static bool DeleteRoom(string RoomID) { if (RoomDAO.CheckRentedRoomByID(RoomID)) { return(false); } return(RoomDAO.DeleteRoom(RoomID)); }
public ControllerClass(HotelContext db) { roomDAO = new RoomDAO(db); guestDAO = new GuestDAO(db); bookingDAO = new BookingDAO(db); dictionaryDAO = new DictionaryDAO(db); this.view = new ViewClass(dictionaryDAO.GetRoomTypes(), dictionaryDAO.GetGuestStatus()); }
public static bool InsertRoom(RoomDTO room) { if (RoomDAO.CheckRoomByID(room.RoomID) || string.IsNullOrWhiteSpace(room.RoomID)) { return(false); } return(RoomDAO.InsertRoom(room)); }
private void LoadBed() { DataTable bed_dt = RoomDAO.GetDataTableBedNoByRoomName(cbxRoom.SelectedValue.ToString()); cbxBed.DataSource = bed_dt; cbxBed.DisplayMember = "bedNo"; cbxBed.ValueMember = "bedNo"; }
private void Awake() { dao = new RoomDAO(); eventHandler = GameEventHandler.Instance; eventHandler.AddHandler(this, UserManager.USER_LOGIN_COMPLETE, OnLoginCompleteHandler); eventHandler.AddHandler(this, ResponseManager.ON_DATA_RECIEVE, OnDataReceive); gameEvent = GameEvent.Instance; }
private void comboBoxRoom_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt1 = RoomDAO.GetDataTableBedNoStatus(comboBoxRoom.SelectedValue.ToString()); comboBoxBedNo.DataSource = dt1; comboBoxBedNo.ValueMember = "bedNo"; comboBoxBedNo.DisplayMember = "bedNo"; view(); }
public static RoomDAO MapToRoomDAO(Room room) { var p = new RoomDAO(); p.Id = room.RoomID; p.RoomNumber = room.RoomNum; return(p); }
/** * Click chọn lịch chiếu */ private void Load_Booking(object sender, EventArgs e) { TileView tileView = sender as TileView; sche_Id = Convert.ToInt32(tileView.GetRowCellValue(tileView.FocusedRowHandle, "id_Sche").ToString()); sche_Name = tileView.GetRowCellValue(tileView.FocusedRowHandle, "StartTime").ToString(); Room_Name = new RoomDAO().getRoomById(Convert.ToInt32(tileView.GetRowCellValue(tileView.FocusedRowHandle, "id_R").ToString())).R_Name; LoadRoom(sche_Id, Room_Name); }
void GetListRoomBySectorId(string SectorId) { List <RoomDTO> roomDTOs = RoomDAO.GetListRoomBySector(SectorId); cbbRoom.DataSource = roomDTOs; cbbRoom.DisplayMember = "RoomId"; cbbRoom_Bill.DataSource = roomDTOs; cbbRoom_Bill.DisplayMember = "RoomId"; }
public JsonResult Delete(int idm) { var x = new RoomDAO().DeleteRoom(idm); return(Json(new { result = x })); }
private void LoadData() { DataTable room_dt = RoomDAO.GetDataTableRoomGroupBy(); cbxRoom.DataSource = room_dt; cbxRoom.DisplayMember = "roomName"; cbxRoom.ValueMember = "roomName"; LoadGridData(); }
public async void DeleteRoomSuccessful() { var result = await RoomService.DeleteRoom(_context, 1, _env.Object); Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); var room = RoomDAO.Get(_context, 1); Assert.Null(room); }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtElectric.Text) || string.IsNullOrEmpty(txtWater.Text)) { MessageBox.Show("TextField is not empty"); } else { int el = int.Parse(txtElectric.Text); int wt = int.Parse(txtElectric.Text); List <Room> list = RoomDAO.getRoomBedByRoomName(comboBoxRoom.SelectedValue.ToString()); int count = 0; for (int i = 0; i < list.Count; i++) { if (list[i].BedStatus == 1) { count++; } } if (count != 0) { int moneyEL = 0; int moneyWt = 0; if ((el - count * 36) < 0) { moneyEL = count * 36 - el; } if ((wt - count * 6) < 0) { moneyWt = count * 6 - wt; } int total = (moneyEL * 2000 + moneyWt * 5000) / count; List <Student> ls = StudentDAO.getStudents(); for (int i = 0; i < ls.Count; i++) { Student stu = ls[i]; if (stu.RoomName == comboBoxRoom.SelectedValue.ToString() && stu.BedNo != 0) { stu.Debt = stu.Debt + total; StudentDAO.Update(stu); } } ElectricityWaterBills eee = new ElectricityWaterBills(1, comboBoxRoom.SelectedValue.ToString(), dateTimePicker1.Value, el, wt, 1); ElectricityWaterBillsDAO.Insert(eee); } else { ElectricityWaterBills eee = new ElectricityWaterBills(1, comboBoxRoom.SelectedValue.ToString(), dateTimePicker1.Value, el, wt, 0); ElectricityWaterBillsDAO.Insert(eee); } DataTable dt1 = ElectricityWaterBillsDAO.GetDataTable(); dataGridView1.DataSource = dt1; } }
public ActionResult Create(PHONG p) { bool idPHONG = false; if (ModelState.IsValid) { var dao = new RoomDAO(); idPHONG = dao.AddRoom(p); } return(Json(idPHONG, JsonRequestBehavior.AllowGet)); }
static void Main(string[] args) { using (HotelContext dB = new HotelContext()) { RoomDAO rd = new RoomDAO(dB); GuestDAO gd = new GuestDAO(dB); BookingDAO bd = new BookingDAO(dB); DictionaryDAO d = new DictionaryDAO(dB); ControllerClass controller = new ControllerClass(dB); controller.Start(); } }