Exemplo n.º 1
0
 public void Mutation_UpdateServicesDetail_InvalidService()
 {
     Database.WriteAsync(realm => realm.Add(new ServicesDetail
     {
         Id      = 20,
         Booking = BookingBusiness.Get(1),
         Service = ServiceBusiness.Get(1),
         Number  = 10
     })).Wait();
     SchemaHelper.ExecuteAndExpectError(
         "Mã dịch vụ không tồn tại",
         @"/_GraphQL/ServicesDetail/mutation.updateServicesDetail.gql",
         new
     {
         input = new
         {
             id      = 20,
             number  = 2,
             service = new
             {
                 id = 100
             }
         }
     },
         p => p.PermissionCleaning = true
         );
 }
Exemplo n.º 2
0
        public void Mutation_ConfirmCleaned_InvalidEmployee()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Employee
                {
                    Id           = "nhanvien_60",
                    Address      = "Địa chỉ",
                    IsActive     = true,
                    Birthdate    = DateTimeOffset.Now,
                    Email        = "*****@*****.**",
                    Gender       = true,
                    Name         = "Quản trị viên",
                    IdentityCard = "123456789",
                    Password     = CryptoHelper.Encrypt("12345678"),
                    PhoneNumber  = "+84 0123456789",
                    Position     = PositionBusiness.Get(1),
                    StartingDate = DateTimeOffset.Now
                });
                realm.Add(new HouseKeeping
                {
                    Id       = 22,
                    Status   = (int)HouseKeeping.StatusEnum.Cleaning,
                    Employee = EmployeeBusiness.Get("nhanvien_60"),
                    Booking  = BookingBusiness.Get(1)
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Nhân viên không được phép xác nhận dọn",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleaned.gql",
                new { id = 22 },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 3
0
        public void Mutation_DeleteServicesDetail_InvalidBooking_Status()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Booking
                {
                    Id               = 200,
                    Status           = (int)Booking.StatusEnum.CheckedOut,
                    EmployeeBooking  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckOut = EmployeeDataAccess.Get("admin"),
                    Bill             = BillDataAccess.Get(1),
                    Room             = RoomDataAccess.Get(1)
                });
                realm.Add(new ServicesDetail
                {
                    Id      = 11,
                    Booking = BookingBusiness.Get(1),
                    Service = ServiceBusiness.Get(200),
                    Number  = 10
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Phòng đã check-out. Không thể cập nhật/xóa chi tiết dịch vụ",
                @"/_GraphQL/ServicesDetail/mutation.deleteServicesDetail.gql",
                new { id = 11 },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 4
0
        public void Mutation_ConfirmCleanedAndServices_InvalidType()
        {
            Database.WriteAsync(realm => realm.Add(new HouseKeeping
            {
                Id       = 34,
                Status   = (int)HouseKeeping.StatusEnum.Cleaning,
                Type     = (int)HouseKeeping.TypeEnum.ExpectedArrival,
                Employee = EmployeeBusiness.Get("admin"),
                Booking  = BookingBusiness.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Chỉ được sử dụng kiểu xác nhận này đối với phòng check-out",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleanedAndServices.gql",
                new
            {
                servicesDetails = new[]
                {
                    new
                    {
                        number  = 1,
                        service = new { id = 1 }
                    },
                    new
                    {
                        number  = 2,
                        service = new { id = 1 }
                    }
                },
                houseKeepingId = 34
            },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 5
0
        public void Mutation_ConfirmCleanedAndServices_InvalidStatus()
        {
            Database.WriteAsync(realm => realm.Add(new HouseKeeping
            {
                Id       = 33,
                Status   = (int)HouseKeeping.StatusEnum.Pending,
                Type     = (int)HouseKeeping.TypeEnum.ExpectedDeparture,
                Employee = EmployeeBusiness.Get("admin"),
                Booking  = BookingBusiness.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Không thể xác nhận dọn phòng",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleanedAndServices.gql",
                new
            {
                servicesDetails = new[]
                {
                    new
                    {
                        number  = 1,
                        service = new { id = 1 }
                    },
                    new
                    {
                        number  = 2,
                        service = new { id = 1 }
                    }
                },
                houseKeepingId = 33
            },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 6
0
        public Booking GetManaged()
        {
            var booking = BookingBusiness.Get(Id);

            if (booking == null)
            {
                throw new Exception("Mã booking không tồn tại");
            }
            return(booking);
        }
Exemplo n.º 7
0
 public void Mutation_DeleteServicesDetail()
 {
     Database.WriteAsync(realm => realm.Add(new ServicesDetail
     {
         Id      = 10,
         Booking = BookingBusiness.Get(1)
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/ServicesDetail/mutation.deleteServicesDetail.gql",
         @"/_GraphQL/ServicesDetail/mutation.deleteServicesDetail.schema.json",
         new { id = 10 },
         p => p.PermissionCleaning = true
         );
 }
Exemplo n.º 8
0
 public void Query_HouseKeeping()
 {
     Database.WriteAsync(realm => realm.Add(new HouseKeeping
     {
         Id       = 40,
         Status   = (int)HouseKeeping.StatusEnum.Cleaning,
         Type     = (int)HouseKeeping.TypeEnum.ExpectedDeparture,
         Employee = EmployeeBusiness.Get("admin"),
         Booking  = BookingBusiness.Get(1)
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/HouseKeeping/query.houseKeeping.gql",
         @"/_GraphQL/HouseKeeping/query.houseKeeping.schema.json",
         new { id = 40 }
         );
 }
Exemplo n.º 9
0
        public void Mutation_ConfirmCleaned()
        {
            Database.WriteAsync(realm => realm.Add(new HouseKeeping
            {
                Id       = 20,
                Status   = (int)HouseKeeping.StatusEnum.Cleaning,
                Employee = EmployeeBusiness.Get("admin"),
                Booking  = BookingBusiness.Get(1)
            })).Wait();

            SchemaHelper.Execute(
                @"/_GraphQL/HouseKeeping/mutation.confirmCleaned.gql",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleaned.schema.json",
                new { id = 20 },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 10
0
        public void Mutation_AssignCleaningService_InvalidStaus()
        {
            Database.WriteAsync(realm => realm.Add(new HouseKeeping
            {
                Id       = 11,
                Status   = (int)HouseKeeping.StatusEnum.Cleaned,
                Employee = EmployeeBusiness.Get("admin"),
                Booking  = BookingBusiness.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Không thể nhận phòng này. Phòng đã hoặc đang được dọn",
                @"/_GraphQL/HouseKeeping/mutation.assignCleaningService.gql",
                new { id = 11 },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 11
0
        public void Mutation_ConfirmCleaned_InvalidStatus()
        {
            Database.WriteAsync(realm => realm.Add(new HouseKeeping
            {
                Id       = 21,
                Status   = (int)HouseKeeping.StatusEnum.Pending,
                Employee = EmployeeBusiness.Get("admin"),
                Booking  = BookingBusiness.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Không thể xác nhận dọn phòng",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleaned.gql",
                new { id = 21 },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 12
0
        public void Mutation_ConfirmCleaned_InvalidType()
        {
            Database.WriteAsync(realm => realm.Add(new HouseKeeping
            {
                Id       = 23,
                Type     = (int)HouseKeeping.TypeEnum.ExpectedDeparture,
                Status   = (int)HouseKeeping.StatusEnum.Cleaning,
                Employee = EmployeeBusiness.Get("admin"),
                Booking  = BookingBusiness.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Không thể sử dụng kiểu xác nhận này đối với phòng check-out",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleaned.gql",
                new { id = 23 },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 13
0
        public void Mutation_ConfirmCleanedAndServices_InvalidService()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Service
                {
                    Id       = 40,
                    IsActive = false,
                    Name     = "Tên dịch vụ",
                    Unit     = "Đơn vị"
                });
                realm.Add(new HouseKeeping
                {
                    Id       = 32,
                    Status   = (int)HouseKeeping.StatusEnum.Cleaning,
                    Type     = (int)HouseKeeping.TypeEnum.ExpectedDeparture,
                    Employee = EmployeeBusiness.Get("admin"),
                    Booking  = BookingBusiness.Get(1)
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Dịch vụ Tên dịch vụ đã ngừng cung cấp",
                @"/_GraphQL/HouseKeeping/mutation.confirmCleanedAndServices.gql",
                new
            {
                servicesDetails = new[]
                {
                    new
                    {
                        number  = 1,
                        service = new { id = 1 }
                    },
                    new
                    {
                        number  = 2,
                        service = new { id = 40 }
                    }
                },
                houseKeepingId = 32
            },
                p => p.PermissionCleaning = true
                );
        }
Exemplo n.º 14
0
        public BookingQuery()
        {
            Field <NonNullGraphType <ListGraphType <NonNullGraphType <BookingType> > > >(
                _List,
                "Trả về một danh sách các đơn đặt phòng",
                resolve: _CheckPermission_List(
                    p => p.PermissionManageRentingRoom,
                    context => BookingBusiness.Get()
                    )
                );

            Field <NonNullGraphType <BookingType> >(
                _Item,
                "Trả về thông tin một đơn đặt phòng",
                _IdArgument(),
                _CheckPermission_Object(
                    p => p.PermissionManageRentingRoom,
                    context => BookingBusiness.Get(_GetId <int>(context))
                    )
                );
        }
Exemplo n.º 15
0
 public void Mutation_UpdateServicesDetail_InvalidService_InActive()
 {
     Database.WriteAsync(realm =>
     {
         realm.Add(new Service
         {
             Id       = 202,
             IsActive = false,
             Name     = "Tên dịch vụ",
             Unit     = "Đơn vị"
         });
         realm.Add(new ServicesDetail
         {
             Id      = 21,
             Booking = BookingBusiness.Get(1),
             Service = ServiceBusiness.Get(1),
             Number  = 10
         });
     }).Wait();
     SchemaHelper.ExecuteAndExpectError(
         "Dịch vụ 202 đã ngừng cung cấp",
         @"/_GraphQL/ServicesDetail/mutation.updateServicesDetail.gql",
         new
     {
         input = new
         {
             id      = 21,
             number  = 2,
             service = new
             {
                 id = 202
             }
         }
     },
         p => p.PermissionCleaning = true
         );
 }