예제 #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
         );
 }
예제 #2
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
                );
        }
예제 #3
0
        public Service GetManaged()
        {
            var service = ServiceBusiness.Get(Id);

            if (service == null)
            {
                throw new Exception("Mã dịch vụ không tồn tại");
            }
            return(service);
        }
예제 #4
0
        public ServiceQuery()
        {
            Field <NonNullGraphType <ListGraphType <NonNullGraphType <ServiceType> > > >(
                _List,
                "Trả về một danh sách các dịch vụ",
                resolve: _CheckPermission_List(
                    p => p.PermissionGetService,
                    context => ServiceBusiness.Get()
                    )
                );

            Field <NonNullGraphType <ServiceType> >(
                _Item,
                "Trả về thông tin một dịch vụ",
                _IdArgument(),
                _CheckPermission_Object(
                    p => p.PermissionGetService,
                    context => ServiceBusiness.Get(_GetId <int>(context))
                    )
                );
        }
예제 #5
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
         );
 }