Exemple #1
0
        public void Mutation_ResetPassword()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Employee
                {
                    Id           = "nhanvien_2",
                    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
                });
            }).Wait();

            SchemaHelper.Execute(
                @"/_GraphQL/Employee/mutation.resetPassword.gql",
                @"/_GraphQL/Employee/mutation.resetPassword.schema.json",
                new { id = "nhanvien_2" },
                p => p.PermissionManageEmployee = true
                );
        }
Exemple #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
                );
        }
Exemple #3
0
        public void PositionContributorGetTest()
        {
            Guid userId   = new Guid("1538694e-12f2-e111-a89d-00155d02e702");
            Guid groupSid = new Guid("aeab580d-df16-42d5-9714-e4e581fc8134");

            var actual = PositionBusiness.Get(false);

            Assert.IsTrue(actual.Count() > 0);
        }
Exemple #4
0
        public Position GetManaged()
        {
            var position = PositionBusiness.Get(Id);

            if (position == null)
            {
                throw new Exception("Mã chức vụ không tồn tại");
            }
            return(position);
        }
Exemple #5
0
 public HttpResponseMessage GetByTeacher()
 {
     try
     {
         var lt = PositionBusiness.Get(true);
         return(Request.CreateResponse(HttpStatusCode.OK, lt));
     }
     catch (Exception exc)
     {
         var logId = LogBusiness.Error(exc);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel(logId)));
     }
 }
Exemple #6
0
        public PositionQuery()
        {
            Field <NonNullGraphType <ListGraphType <NonNullGraphType <PositionType> > > >(
                _List,
                "Trả về một danh sách các chức vụ",
                resolve: _CheckPermission_List(
                    p => p.PermissionManagePosition,
                    context => PositionBusiness.Get()
                    )
                );

            Field <NonNullGraphType <PositionType> >(
                _Item,
                "Trả về thông tin một chức vụ",
                _IdArgument(),
                _CheckPermission_Object(
                    p => p.PermissionManagePosition,
                    context => PositionBusiness.Get(_GetId <int>(context))
                    )
                );
        }
Exemple #7
0
        public void Mutation_CheckOut_InvalidEmployee()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Employee
                {
                    Id           = "nhanvien_1",
                    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 Booking
                {
                    Id               = 22,
                    Status           = (int)Booking.StatusEnum.RequestedCheckOut,
                    EmployeeBooking  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckOut = EmployeeDataAccess.Get("nhanvien_1"),
                    Bill             = BillDataAccess.Get(1),
                    Room             = RoomDataAccess.Get(1)
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Nhân viên không được phép check-out",
                @"/_GraphQL/Booking/mutation.checkOut.gql",
                new { id = 22 },
                p => p.PermissionManageRentingRoom = true
                );
        }