public void Mutation_CreateBill() { Database.WriteAsync(realm => realm.Add(new Room { Id = 120, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.Execute( @"/_GraphQL/Bill/mutation.createBill.gql", @"/_GraphQL/Bill/mutation.createBill.schema.json", new { bookings = new[] { new { bookCheckInTime = DateTimeOffset.Now.AddDays(1), bookCheckOutTime = DateTimeOffset.Now.AddDays(2), room = new { id = 120 }, listOfPatrons = new[] { new { id = 1 } } } }, bill = new { patron = new { id = 1 } } }, p => p.PermissionManageRentingRoom = true ); }
public void Mutation_CreateBill_InvalidRoom_InActive() { Database.WriteAsync(realm => realm.Add(new Room { Id = 121, IsActive = false, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.ExecuteAndExpectError( "Phòng 121 đã ngừng hoạt động", @"/_GraphQL/Bill/mutation.createBill.gql", new { bookings = new[] { new { bookCheckInTime = DateTimeOffset.Now.AddDays(1), bookCheckOutTime = DateTimeOffset.Now.AddDays(2), room = new { id = 121 }, listOfPatrons = new[] { new { id = 1 } } } }, bill = new { patron = new { id = 1 } } }, p => p.PermissionManageRentingRoom = true ); }
public void Mutation_SetIsActiveRoom_InvalidFloor_InActive() { Database.WriteAsync(realm => { realm.Add(new Floor { Id = 110, Name = "Tầng tạo ra để xóa", IsActive = false }); realm.Add(new Room { Id = 21, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(110), RoomKind = RoomKindBusiness.Get(1) }); }).Wait(); SchemaHelper.ExecuteAndExpectError( "Loại phòng thuộc tầng đã bị vô hiệu hóa. Không thể kích hoạt", @"/_GraphQL/Room/mutation.setIsActiveRoom.gql", new { id = 21, isActive = true }, p => p.PermissionManageMap = true ); }
public void Mutation_AddBookingToBill_InvalidBill() { Database.WriteAsync(realm => realm.Add(new Room { Id = 201, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.ExecuteAndExpectError( "Mã hóa đơn không tồn tại", @"/_GraphQL/Booking/mutation.addBookingToBill.gql", new { booking = new { bookCheckInTime = DateTimeOffset.Now.AddDays(1), bookCheckOutTime = DateTimeOffset.Now.AddDays(2), room = new { id = 201 }, listOfPatrons = new[] { new { id = 1 } } }, bill = new { id = 1 } }, p => p.PermissionManageRentingRoom = true ); }
public void Mutation_BookAndCheckIn_InvalidRoom_Overlap() { Database.WriteAsync(realm => realm.Add(new Room { Id = 111, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.ExecuteAndExpectError( "Có booking trùng nhau", @"/_GraphQL/Bill/mutation.bookAndCheckIn.gql", new { bookings = new[] { new { bookCheckOutTime = DateTimeOffset.Now.AddDays(2), room = new { id = 111 }, listOfPatrons = new[] { new { id = 1 } } } }, bill = new { patron = new { id = 1 } } }, p => p.PermissionManageRentingRoom = true ); }
public void Mutation_UpdateRoom_InvalidRoomKind() { Database.WriteAsync(realm => realm.Add(new Room { Id = 33, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.ExecuteAndExpectError( "Mã loại phòng không tồn tại", @"/_GraphQL/Room/mutation.updateRoom.gql", new { input = new { id = 33, name = "Phòng 2", roomKind = new { id = 100 }, floor = new { id = 1 } } }, p => p.PermissionManageMap = true ); }
public void Mutation_UpdateRoom_InvalidRoom_InActive() { Database.WriteAsync(realm => realm.Add(new Room { Id = 35, IsActive = false, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.ExecuteAndExpectError( "Phòng 35 đã ngưng hoại động. Không thể cập nhật/xóa!", @"/_GraphQL/Room/mutation.updateRoom.gql", new { input = new { id = 35, name = "Phòng 2", roomKind = new { id = 1 }, floor = new { id = 1 } } }, p => p.PermissionManageMap = true ); }
public void Mutation_UpdateRoom() { Database.WriteAsync(realm => realm.Add(new Room { Id = 30, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.Execute( @"/_GraphQL/Room/mutation.updateRoom.gql", @"/_GraphQL/Room/mutation.updateRoom.schema.json", new { input = new { id = 30, name = "Phòng 2", roomKind = new { id = 1 }, floor = new { id = 1 } } }, p => p.PermissionManageMap = true ); }
public FloorMutation() { Field <NonNullGraphType <FloorType> >( _Creation, "Tạo và trả về một tầng mới", _InputArgument <FloorCreateInput>(), _CheckPermission_TaskObject( p => p.PermissionManageMap, context => FloorBusiness.Add(_GetInput(context)) ) ); Field <NonNullGraphType <FloorType> >( _Updation, "Cập nhật và trả về một tầng vừa cập nhật", _InputArgument <FloorUpdateInput>(), _CheckPermission_TaskObject( p => p.PermissionManageMap, context => FloorBusiness.Update(_GetInput(context)) ) ); Field <NonNullGraphType <StringGraphType> >( _Deletion, "Xóa một tầng", _IdArgument(), _CheckPermission_String( p => p.PermissionManageMap, context => { FloorBusiness.Delete(_GetId <int>(context)); return("Xóa thành công"); } ) ); Field <NonNullGraphType <StringGraphType> >( _SetIsActive, "Cập nhật trạng thái hoạt động của tầng", new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" }, new QueryArgument <NonNullGraphType <BooleanGraphType> > { Name = "isActive" } ), _CheckPermission_String( p => p.PermissionManageMap, context => { var id = context.GetArgument <int>("id"); var isActive = context.GetArgument <bool>("isActive"); FloorBusiness.SetIsActive(id, isActive); return("Cập nhật trạng thái thành công"); } ) ); }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here FloorBusiness floorBusiness = new FloorBusiness(new FloorDataAccess()); bool result = floorBusiness.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Floor/Edit/5 public ActionResult Edit(int id) { FloorBusiness floorBusiness = new FloorBusiness(new FloorDataAccess()); Floor floor = floorBusiness.GetFloor(id); FloorModel floorModel = new FloorModel { FloorId = floor.FloorId, FloorName = floor.FloorName, CreatedByUserId = floor.CreatedByUserId, CreatedDate = floor.CreatedDate, ModifiedByUserId = floor.ModifiedByUserId, ModifiedDate = floor.ModifiedDate }; return(View(floorModel)); }
public void Mutation_SetIsActiveRoom() { Database.WriteAsync(realm => realm.Add(new Room { Id = 20, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) })).Wait(); SchemaHelper.Execute( @"/_GraphQL/Room/mutation.setIsActiveRoom.gql", @"/_GraphQL/Room/mutation.setIsActiveRoom.schema.json", new { id = 20, isActive = true }, p => p.PermissionManageMap = true ); }
public void Mutation_UpdateRoom_InvalidRoomKind_InActive() { Database.WriteAsync(realm => { realm.Add(new RoomKind { Id = 102, Name = "Tên loại phòng", AmountOfPeople = 1, NumberOfBeds = 1, IsActive = false }); realm.Add(new Room { Id = 34, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) }); }).Wait(); SchemaHelper.ExecuteAndExpectError( "Loại phòng có ID: 102 đã ngưng hoại động", @"/_GraphQL/Room/mutation.updateRoom.gql", new { input = new { id = 34, name = "Phòng 2", roomKind = new { id = 102 }, floor = new { id = 1 } } }, p => p.PermissionManageMap = true ); }
public void Mutation_UpdateRoom_InvalidFloor_InActive() { Database.WriteAsync(realm => { realm.Add(new Floor { Id = 102, Name = "Tầng tạo ra để kiểm tra inactive", IsActive = false }); realm.Add(new Room { Id = 32, IsActive = true, Name = "Tên phòng", Floor = FloorBusiness.Get(1), RoomKind = RoomKindBusiness.Get(1) }); }).Wait(); SchemaHelper.ExecuteAndExpectError( "Tầng có ID: 102 đã ngưng hoại động", @"/_GraphQL/Room/mutation.updateRoom.gql", new { input = new { id = 32, name = "Phòng 2", roomKind = new { id = 1 }, floor = new { id = 102 } } }, p => p.PermissionManageMap = true ); }
// GET: Floor public ActionResult Index() { FloorBusiness floorBusiness = new FloorBusiness(new FloorDataAccess()); List <Floor> floorList = floorBusiness.GetFloors(); List <FloorModel> floorModelList = new List <FloorModel>(); foreach (Floor floor in floorList) { FloorModel floorModel = new FloorModel { FloorId = floor.FloorId, FloorName = floor.FloorName, CreatedByUserId = floor.CreatedByUserId, CreatedDate = floor.CreatedDate, ModifiedByUserId = floor.ModifiedByUserId, ModifiedDate = floor.ModifiedDate }; floorModelList.Add(floorModel); } return(View(floorModelList)); }
public FloorQuery() { Field <NonNullGraphType <ListGraphType <NonNullGraphType <FloorType> > > >( _List, "Trả về một danh sách các tầng", resolve: _CheckPermission_List( p => p.PermissionGetMap, context => FloorBusiness.Get() ) ); Field <NonNullGraphType <FloorType> >( _Item, "Trả về thông tin một tầng", _IdArgument(), _CheckPermission_Object( p => p.PermissionGetMap, context => FloorBusiness.Get(_GetId <int>(context)) ) ); }
public ActionResult Index() { ElevatorBusiness elevatorBusiness = new ElevatorBusiness(new ElevatorDataAccess()); LookupBusiness lookupBusiness = new LookupBusiness(new LookupDataAccess()); FloorBusiness floorBusiness = new FloorBusiness(new FloorDataAccess()); List <ElevatorCoreModel.Elevator> elevatorList = elevatorBusiness.GetElevators(); List <Floor> floorList = floorBusiness.GetFloors(); List <ElevatorModel> elevatorModelList = new List <ElevatorModel>(); foreach (ElevatorCoreModel.Elevator elevator in elevatorList) { ElevatorModel elevatorModel = new ElevatorModel { ElevatorId = elevator.ElevatorId, ElevatorName = elevator.ElevatorName, FloorDuration = elevator.FloorDuration, MainStatus = (Enums.MainStatus)Enum.Parse(typeof(Enums.MainStatus), lookupBusiness.GetLookupValue(elevator.MainStatusId)), MaxWeight = elevator.MaxWeight }; elevatorModelList.Add(elevatorModel); } List <FloorModel> floorModelList = new List <FloorModel>(); foreach (Floor floor in floorList) { FloorModel floorModel = new FloorModel { FloorId = floor.FloorId, FloorName = floor.FloorName, CreatedDate = floor.CreatedDate, CreatedByUserId = floor.CreatedByUserId, ModifiedByUserId = floor.ModifiedByUserId, ModifiedDate = floor.ModifiedDate }; floorModelList.Add(floorModel); } ViewBag.elevatorList = elevatorModelList; ViewBag.floorList = floorModelList; return(View()); }
public ActionResult Edit(int id, FormCollection formCollection) { //try //{ // TODO: Add update logic here FloorBusiness floorBusiness = new FloorBusiness(new FloorDataAccess()); Floor floor = new Floor { CreatedByUserId = 1, // (int)Session["FloorId"]; ModifiedByUserId = 2, // (int)Session["FloorId"]; FloorId = id, FloorName = formCollection["FloorName"] }; floorBusiness.Update(floor); return(RedirectToAction("Index")); //} //catch //{ // return View(); //} }
public ActionResult Create(FormCollection formCollection) { // try // { FloorBusiness floorBusiness = new FloorBusiness(new FloorDataAccess()); Floor floor = new Floor { FloorId = Convert.ToInt32(formCollection["FloorId"]), FloorName = Convert.ToString(formCollection["FloorName"]), CreatedByUserId = 1, // (int)Session["FloorId"]; ModifiedByUserId = 2, // (int)Session["FloorId"]; CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, }; floorBusiness.Create(floor); return(RedirectToAction("Index")); //} //catch //{ // return View(); //} }
private void lookUpEditBuilding_EditValueChanged(object sender, EventArgs e) { InitLookUpEdit(lookUpEditFloor, FloorBusiness.GetFloorByBuildingId(lookUpEditBuilding.Text), "FloorId", "FloorId"); lookUpEditFloor.Properties.Columns["BuildingId"].Visible = false; }
public void GetFloorByBuildingIdTest(string buildingId) { var actual = FloorBusiness.GetFloorByBuildingId(buildingId).Count; Assert.AreEqual(10, actual); }
public Floor GetManaged() { var floor = FloorBusiness.Get(Id); return(floor); }