public void EmployeeCanBeFoundById()
        {
            var employees      = employeeBusiness.GetAll();
            var lastEmployeeId = employees[employees.Count - 1].Id;

            Assert.AreEqual(lastEmployeeId, employeeBusiness.Get(lastEmployeeId).Id,
                            "This employee has a different Id");
        }
Beispiel #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
                );
        }
Beispiel #3
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
                );
        }
Beispiel #4
0
        public void TestMethod1()
        {
            var mockEmployeeBusiness = new Mock <IEmployeeBusiness>();
            var mockRepo             = new Mock <IGenericRepository <Employee> >();

            AutoMapperProfile.Run();
            var mockMapper = new Mock <IMapper>();



            IQueryable <Employee> employees = new Employee[] { new Employee()
                                                               {
                                                                   FirstName = "Alejandro", Id = 1, ContractType = new ContractType {
                                                                       Id = 1
                                                                   }, Salary = 200
                                                               } }.AsQueryable();

            mockRepo.Setup(repo => repo.GetAll()).Returns(employees);
            IPaymentFactory   paymentFac        = new PaymentFactory();
            IEmployeeBusiness _employeeBusiness = new EmployeeBusiness(mockRepo.Object, paymentFac);
            var model = _employeeBusiness.Get(1);

            //Salary = 200
            //MonthlySalary (MonthtlySalary * 12)
            // 200 * 12 = 2400
            Assert.IsTrue(model.AnnualSalary.Equals(2400));
        }
Beispiel #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
                );
        }
Beispiel #6
0
        public void Mutation_UpdateRate_InvalidRoomKind()
        {
            Database.WriteAsync(realm => realm.Add(new Rate
            {
                Id       = 21,
                RoomKind = RoomKindBusiness.Get(1),
                Employee = EmployeeBusiness.Get("admin")
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Mã loại phòng không tồn tại",
                @"/_GraphQL/Rate/mutation.updateRate.gql",
                new
            {
                input = new
                {
                    id                 = 21,
                    dayRate            = 5,
                    nightRate          = 5,
                    weekRate           = 5,
                    monthRate          = 5,
                    lateCheckOutFee    = 5,
                    earlyCheckInFee    = 5,
                    effectiveStartDate = DateTimeOffset.MinValue,
                    roomKind           = new
                    {
                        id = 100
                    }
                }
            },
                p => p.PermissionManageRate = true
                );
        }
Beispiel #7
0
        public Employee GetManaged()
        {
            var employee = EmployeeBusiness.Get(Id);

            if (employee == null)
            {
                throw new Exception("Tên đăng nhập không tồn tại");
            }
            return(employee);
        }
Beispiel #8
0
        public void Mutation_UpdateVolatilityRate_InvalidRoomKind_InActive()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new RoomKind
                {
                    Id             = 201,
                    Name           = "Tên loại phòng",
                    AmountOfPeople = 1,
                    NumberOfBeds   = 1,
                    IsActive       = false
                });
                realm.Add(new VolatilityRate
                {
                    Id       = 22,
                    RoomKind = RoomKindBusiness.Get(1),
                    Employee = EmployeeBusiness.Get("admin")
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Loại phòng 201 đã ngưng hoại động",
                @"/_GraphQL/VolatilityRate/mutation.updateVolatilityRate.gql",
                new
            {
                input = new
                {
                    id                   = 22,
                    dayRate              = 1,
                    nightRate            = 1,
                    weekRate             = 1,
                    monthRate            = 1,
                    lateCheckOutFee      = 1,
                    earlyCheckInFee      = 1,
                    effectiveStartDate   = "0001-01-01T00:00:00+00:00",
                    effectiveEndDate     = "0001-01-01T00:00:00+00:00",
                    effectiveOnMonday    = true,
                    effectiveOnTuesday   = true,
                    effectiveOnWednesday = true,
                    effectiveOnThursday  = true,
                    effectiveOnFriday    = true,
                    effectiveOnSaturday  = true,
                    effectiveOnSunday    = true,
                    roomKind             = new
                    {
                        id = 201
                    }
                }
            },
                p => p.PermissionManageRate = true
                );
        }
Beispiel #9
0
        private void UpdateTextboxes(int id)
        {
            var employee = employeeBusiness.Get(id);
            var role     = txtRole;
            var name     = txtNam;
            var password = txtPassword;
            var city     = txtCity;

            role.Text     = employee.Role;
            name.Text     = employee.Name;
            password.Text = employee.Password;
            city.Text     = employee.City;
        }
 private void cmiDeleteEmployee_Click(object sender, EventArgs e)
 {
     if (dgvEmployees.SelectedRows.Count > 0)
     {
         DialogResult result = MessageBox.Show("Seçilen çalışanı silmek istediğinizden emin misniz?", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             _selectedID = (int)dgvEmployees.SelectedRows[0].Cells["ID"].Value;
             Employee emp = _empBLL.Get(_selectedID);
             _empBLL.Remove(emp);
         }
     }
 }
        public static Employee GetEmployee(ResolveFieldContext <object> context)
        {
            var id = GetEmployeeId(context);

            var employee = EmployeeBusiness.Get(id);

            if (employee == null)
            {
                throw new Exception("Không tìm thấy tên đăng nhập trong hệ thống");
            }

            return(employee);
        }
Beispiel #12
0
        private static async Task <ExecuteAsyncResult> ExecuteAsync(
            string queryPath,
            object variableObject           = null,
            Action <Position> setPermission = null
            )
        {
            var variable = "{}";

            if (variableObject is string)
            {
                variable = File.ReadAllText(((string)variableObject).TrimStart('/'));
            }
            else if (variableObject != null)
            {
                variable = JsonConvert.SerializeObject(variableObject);
            }
            var query = File.ReadAllText(queryPath.TrimStart('/'));

            var User = new ClaimsPrincipal(
                new ClaimsIdentity(
                    new[] { new Claim(ClaimTypes.Name, Constant.adminName) }
                    )
                );

            var position = EmployeeBusiness.Get(Constant.adminName).Position;

            if (setPermission != null)
            {
                PositionBusiness.UpdateForHelper(setPermission, position);
            }

            var result = await Initializer.DocumentExecuter.ExecuteAsync(_ =>
            {
                _.Schema      = Initializer.Schema;
                _.Query       = query;
                _.Inputs      = JObject.Parse(variable).ToInputs();
                _.UserContext = new GraphQLUserContext {
                    User = User
                };
                _.ValidationRules = DocumentValidator.CoreRules().Concat(Initializer.ValidationRule).ToList();
            }).ConfigureAwait(false);

            return(new ExecuteAsyncResult
            {
                Result = result,
                Query = query,
                Variable = variable
            });
        }
Beispiel #13
0
 public void Query_Rate()
 {
     Database.WriteAsync(realm => realm.Add(new Rate
     {
         Id       = 30,
         RoomKind = RoomKindBusiness.Get(1),
         Employee = EmployeeBusiness.Get("admin")
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/Rate/query.rate.gql",
         @"/_GraphQL/Rate/query.rate.schema.json",
         new { id = 30 },
         p => p.PermissionGetRate = true
         );
 }
Beispiel #14
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 }
         );
 }
Beispiel #15
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
                );
        }
Beispiel #16
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
                );
        }
Beispiel #17
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
                );
        }
Beispiel #18
0
 public void Query_Receipt()
 {
     Database.WriteAsync(realm => realm.Add(new Receipt
     {
         Id                = 10,
         Money             = 1,
         BankAccountNumber = "11111",
         Bill              = BillBusiness.Get(1),
         Employee          = EmployeeBusiness.Get(Constant.adminName)
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/Receipt/query.receipt.gql",
         @"/_GraphQL/Receipt/query.receipt.schema.json",
         new { id = 10 },
         p => p.PermissionGetAccountingVoucher = true
         );
 }
Beispiel #19
0
 public void Mutation_DeleteRate()
 {
     Database.WriteAsync(realm => realm.Add(new Rate
     {
         Id       = 10,
         RoomKind = RoomKindBusiness.Get(1),
         Employee = EmployeeBusiness.Get("admin")
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/Rate/mutation.deleteRate.gql",
         @"/_GraphQL/Rate/mutation.deleteRate.schema.json",
         new
     {
         id = 10
     },
         p => p.PermissionManageRate = true
         );
 }
Beispiel #20
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
                );
        }
Beispiel #21
0
        public void Mutation_UpdateRate_InvalidRoomKind_InActive()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Rate
                {
                    Id       = 22,
                    RoomKind = RoomKindBusiness.Get(1),
                    Employee = EmployeeBusiness.Get("admin")
                });
                realm.Add(new RoomKind
                {
                    Id             = 110,
                    Name           = "Tên loại phòng",
                    AmountOfPeople = 1,
                    NumberOfBeds   = 1,
                    IsActive       = false
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Loại phòng 110 đã ngưng hoại động",
                @"/_GraphQL/Rate/mutation.updateRate.gql",
                new
            {
                input = new
                {
                    id                 = 22,
                    dayRate            = 5,
                    nightRate          = 5,
                    weekRate           = 5,
                    monthRate          = 5,
                    lateCheckOutFee    = 5,
                    earlyCheckInFee    = 5,
                    effectiveStartDate = DateTimeOffset.MinValue,
                    roomKind           = new
                    {
                        id = 110
                    }
                }
            },
                p => p.PermissionManageRate = true
                );
        }
Beispiel #22
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
                );
        }
Beispiel #23
0
        public EmployeeQuery()
        {
            Field <NonNullGraphType <ListGraphType <NonNullGraphType <EmployeeType> > > >(
                _List,
                "Trả về một danh sách các nhân viên",
                resolve: _CheckPermission_List(
                    p => p.PermissionManageEmployee,
                    context => EmployeeBusiness.Get()
                    )
                );

            Field <NonNullGraphType <EmployeeType> >(
                _Item,
                "Trả về thông tin một nhân viên",
                _IdArgument(),
                _CheckPermission_Object(
                    p => p.PermissionManageEmployee,
                    context => EmployeeBusiness.Get(_GetId <string>(context))
                    )
                );
        }
Beispiel #24
0
 public void Mutation_UpdateVolatilityRate_InvalidRoomKind()
 {
     Database.WriteAsync(realm => realm.Add(new VolatilityRate
     {
         Id       = 21,
         RoomKind = RoomKindBusiness.Get(1),
         Employee = EmployeeBusiness.Get("admin")
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/VolatilityRate/mutation.updateVolatilityRate.gql",
         @"/_GraphQL/VolatilityRate/mutation.updateVolatilityRate.schema.json",
         new
     {
         input = new
         {
             id                   = 21,
             dayRate              = 1,
             nightRate            = 1,
             weekRate             = 1,
             monthRate            = 1,
             lateCheckOutFee      = 1,
             earlyCheckInFee      = 1,
             effectiveStartDate   = "0001-01-01T00:00:00+00:00",
             effectiveEndDate     = "0001-01-01T00:00:00+00:00",
             effectiveOnMonday    = true,
             effectiveOnTuesday   = true,
             effectiveOnWednesday = true,
             effectiveOnThursday  = true,
             effectiveOnFriday    = true,
             effectiveOnSaturday  = true,
             effectiveOnSunday    = true,
             roomKind             = new
             {
                 id = 1
             }
         }
     },
         p => p.PermissionManageRate = true
         );
 }
        private void FillForm()
        {
            _empBLL = new EmployeeBusiness(_user);
            if (_selectedId > 0)
            {
                try
                {
                    _emp = _empBLL.Get(_selectedId);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                txtID.Text        = _emp.ID.ToString();
                txtFirstName.Text = _emp.FirstName;
                txtLastName.Text  = _emp.LastName;
                txtEmail.Text     = _emp.Email;
                txtPassword.Text  = _emp.Password;
            }

            FillRoleCmb();
        }