public EmployeeRelativeValidator(ICategoryRepository categoryRepository)
        {
            this._categoryRepository = categoryRepository;

            RuleFor(x => x.EmployeeCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20));

            RuleFor(x => x.OriginProvinceCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã tỉnh thành"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tỉnh thành", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tỉnh thành", 20))
            .Must(IsValidProvinceCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã tỉnh thành"));


            RuleFor(x => x.OriginAddress).NotEmpty().WithMessage(CommonMessageGlobal.Require("Địa chỉ"));

            RuleFor(x => x.Job).NotEmpty().WithMessage(CommonMessageGlobal.Require("Công việc"));

            RuleFor(x => x.Phone).NotEmpty().WithMessage(CommonMessageGlobal.Require("Số điện thoại"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Số điện thoại", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Số điện thoại", 20));

            RuleFor(x => x.Name).NotEmpty().WithMessage(CommonMessageGlobal.Require("Họ và tên"));

            RuleFor(x => x.RelativeType).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã mối quan hệ"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã mối quan hệ", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã mối quan hệ", 20))
            .Must(IsValidRelativeCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã mối quan hệ"));
        }
Example #2
0
        public ActionResult <CommonResponeModel> SaveChangeContact(EmployeeContactDetailRequestModel model)
        {
            var databaseObject = new Employee();
            int result;

            if (model.Id == 0)
            {
                Result = new ErrorResult(ActionType.Insert, CommonMessageGlobal.NotExist("Mã nhân viên"));
                return(GetCommonRespone());
            }
            else
            {
                databaseObject = employeeRepository.GetById(model.Id);
                databaseObject.MapFrom(model);
                databaseObject.InitBeforeSave(RequestUsername, InitType.Update);
                databaseObject.InitDefault();

                result = employeeRepository.Update(databaseObject);
            }

            if (result > 0)
            {
                Result = new SuccessResult(ActionType.Edit, AppGlobal.SaveChangeSuccess);
            }
            else
            {
                Result = new ErrorResult(ActionType.Edit, AppGlobal.SaveChangeFalse);
            }

            return(GetCommonRespone());
        }
Example #3
0
        public ContractTypeSaveChangeValidator()
        {
            RuleFor(x => x.Id).NotEmpty().WithMessage(CommonMessageGlobal.Require("Id"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Id", 0));

            RuleFor(x => x.TextName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên loại hợp đồng"));
            RuleFor(x => x.TemplatePath).NotEmpty().WithMessage(CommonMessageGlobal.Require("Đường dẫn "));
        }
Example #4
0
        public EmployeeSaveChangeValidator(ICategoryRepository categoryRepository)
        {
            this._categoryRepository = categoryRepository;

            RuleFor(x => x.FirstName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Họ nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Họ nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Họ nhân viên", 20));

            RuleFor(x => x.LastName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tên nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Tên nhân viên", 20));

            RuleFor(x => x.FullName)
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Họ và tên nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Họ và tên nhân viên", 256));

            RuleFor(x => x.DepartmentCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã bộ phận"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã bộ phận", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã bộ phận", 20))
            .Must(IsValidDepartmentCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã bộ phận"));

            RuleFor(x => x.ReligionCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tôn giáo", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tôn giáo", 20));

            RuleFor(x => x.GroupCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tổ nhóm", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tổ nhóm", 20));

            RuleFor(x => x.PersonalEmail).EmailAddress().WithMessage(CommonMessageGlobal.Invalid("Email cá nhân"));

            RuleFor(x => x.CompanyEmail).EmailAddress().WithMessage(CommonMessageGlobal.Invalid("Email công ty"));

            RuleFor(x => x.StatusCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Trạng thái nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Trạng thái nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Trạng thái nhân viên", 20))
            .Must(IsValidStatusCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Trạng thái nhân viên"));

            RuleFor(x => x.TitleCode)
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Danh xưng", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Danh xưng", 20));


            RuleFor(x => x.GenderCode)
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Giới tính", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Giới tính", 20));

            RuleFor(x => x.PositionCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Vị trí", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Vị trí", 20));

            RuleFor(x => x.BankCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Ngân hàng", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Ngân hàng", 20));

            RuleFor(x => x.JobCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Công việc", 2))
            .MaximumLength(10).WithMessage(CommonMessageGlobal.Maximum("Công việc", 10));

            RuleFor(x => x.LaborGroupCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Nhóm lao động", 2))
            .MaximumLength(10).WithMessage(CommonMessageGlobal.Maximum("Nhóm lao động", 10));
        }
Example #5
0
        public RoleGroupSaveChangeValidator()
        {
            RuleFor(x => x.Id).NotEmpty().WithMessage(CommonMessageGlobal.Require("Id"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Id", 0));

            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã", 20));
        }
Example #6
0
        public ShiftCreateValidator()
        {
            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã ca làm việc"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã ca làm việc", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã ca làm việc", 20));

            RuleFor(x => x.Name).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên ca làm việc"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tên ca làm việc", 2))
            .MaximumLength(256).WithMessage(CommonMessageGlobal.Maximum("Tên ca làm việc", 256));
        }
Example #7
0
        public UserLoginValidator()
        {
            RuleFor(x => x.Username).NotEmpty().WithMessage(CommonMessageGlobal.Require("Username"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Username", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Username", 50));

            RuleFor(x => x.Password).NotEmpty().WithMessage(CommonMessageGlobal.Require("Password"))
            .MinimumLength(4).WithMessage(CommonMessageGlobal.Minimum("Password", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Password", 256));
        }
Example #8
0
        public ShiftSaveChangeValidator()
        {
            RuleFor(x => x.Id).NotEmpty().WithMessage(CommonMessageGlobal.Require("Id"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Id", 0));

            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã ca làm việc"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã ca làm việc", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã ca làm việc", 20));

            RuleFor(x => x.Name).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên ca làm việc"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tên ca làm việc", 2))
            .MaximumLength(256).WithMessage(CommonMessageGlobal.Maximum("Tên ca làm việc", 256));
        }
        public RecruitmentPlanSaveChangeValidator(ICategoryRepository _categoryRepository)
        {
            categoryRepository = _categoryRepository;

            RuleFor(x => x.Title).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tiêu đề kế hoạch tuyển dụng"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tiêu đề kế hoạch tuyển dụng", 2));

            RuleFor(x => x.DepartmentCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã bộ phận"))
            .Must(IsValidDepartmentCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã bộ phận"));

            RuleFor(x => x.JobCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Vị trí công việc"))
            .Must(IsValidJobCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Vị trí công việc"));
        }
Example #10
0
        public CheckInOutDeviceUpdateValidator(ICategoryRepository categoryRepository)
        {
            this._categoryRepository = categoryRepository;

            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã thiết bị"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 50));


            RuleFor(x => x.StatusCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Trạng thái"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Trạng thái", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Trạng thái", 20))
            .Must(IsValidStatusCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Trạng thái"));
        }
Example #11
0
        public CandidatePaperCreateValidator(ICandidateRepository candidateRepository, ICategoryRepository categoryRepository)
        {
            this._candidateRepository = candidateRepository;
            this._categoryRepository  = categoryRepository;

            RuleFor(x => x.CandidateCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã ứng viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã ứng viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã ứng viên", 20))
            .Must(IsValidCandidateCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã ứng viên"));

            RuleFor(x => x.TypeCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Loại giấy tờ"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Loại giấy tờ", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Loại giấy tờ", 20))
            .Must(IsValidTypeCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Loại giấy tờ"));
        }
        public RoleGroupDetailCreateValidator(IRoleGroupRepository roleGroupRepository, ICategoryRepository categoryRepository)
        {
            this._categoryRepository  = categoryRepository;
            this._roleGroupRepository = roleGroupRepository;

            RuleFor(x => x.RoleGroupCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhóm phân quyền"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhóm phân quyền", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhóm phân quyền", 20))
            .Must(IsValidRoleGroupCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã hợp đồng"));

            RuleFor(x => x.NavigationCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã phân quyền"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phân quyền", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phân quyền", 20))
            .Must(IsValidNavigationCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã phân quyền"));
        }
        public ShiftEmployeeSaveChangeValidator(IEmployeeRepository employeeRepository, IShiftRepository shiftRepository)
        {
            this._employeeRepository = employeeRepository;
            this._shiftRepository    = shiftRepository;

            RuleFor(x => x.EmployeeCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20))
            .Must(IsValidEmployeeCode).WithMessage(CommonMessageGlobal.Invalid("Mã nhân viên"));

            RuleFor(x => x.ShiftCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã ca làm việc"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã ca làm việc", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã ca làm việc", 20))
            .Must(IsValidShiftCode).WithMessage(CommonMessageGlobal.Invalid("Mã ca làm việc"));
        }
Example #14
0
        public TrainingCourseSaveChangeValidator(ITrainingCourseRepository trainingCourseRepository)
        {
            this._trainingCourseRepository = trainingCourseRepository;

            RuleFor(x => x.Code).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã khóa đào tạo", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã khóa đào tạo", 20));

            RuleFor(x => x.Name).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã khóa đào tạo"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã khóa đào tạo", 2))
            .MaximumLength(256).WithMessage(CommonMessageGlobal.Maximum("Mã khóa đào tạo", 256));

            RuleFor(x => x.ParentCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã khóa đào tạo cha", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã khóa đào tạo cha", 20))
            .Must(IsValidParentCode).WithMessage(CommonMessageGlobal.Invalid("Mã khóa đào tạo cha"));
        }
        public TrainingCourseEmployeeCreateValidator(IEmployeeRepository employeeRepository, ITrainingCourseRepository trainingCourseRepository)
        {
            this._employeeRepository       = employeeRepository;
            this._trainingCourseRepository = trainingCourseRepository;

            RuleFor(x => x.EmployeeCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20))
            .Must(IsValidEmployeeCode).WithMessage(CommonMessageGlobal.Invalid("Mã nhân viên"));

            RuleFor(x => x.TrainingCourseCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã ca làm việc"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã ca làm việc", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã ca làm việc", 20))
            .Must(IsValidCourseCode).WithMessage(CommonMessageGlobal.Invalid("Mã ca làm việc"));
        }
Example #16
0
        public HolidayCreateValidator()
        {
            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã", 20));

            RuleFor(x => x.Name).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tên", 2))
            .MaximumLength(256).WithMessage(CommonMessageGlobal.Maximum("Tên", 256));

            RuleFor(x => x.StartDate).NotEmpty().WithMessage(CommonMessageGlobal.Require("Từ ngày"));
            RuleFor(x => x.EndDate).NotEmpty().WithMessage(CommonMessageGlobal.Require("Đến ngày"));

            RuleFor(x => x.SalaryIncreasePercent).NotEmpty().WithMessage(CommonMessageGlobal.Require("Số tiền tăng"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Số tiền tăng", 0));
        }
Example #17
0
        public CandidateSaveChangeValidator()
        {
            RuleFor(x => x.Id).NotEmpty().WithMessage(CommonMessageGlobal.Require("Id"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Id", 0));

            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20));

            RuleFor(x => x.FullName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Họ và tên nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Họ và tên nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Họ và tên nhân viên", 256));

            RuleFor(x => x.TemporaryProvinceCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã tỉnh tạm trú"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tỉnh tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tỉnh tạm trú", 20));

            RuleFor(x => x.TemporaryDistrictCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã quận/huyện tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã quận/huyện tạm trú", 20));

            RuleFor(x => x.TemporaryWardCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phường/xã tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phường/xã tạm trú", 20));

            RuleFor(x => x.TemporaryAddress).NotEmpty().WithMessage(CommonMessageGlobal.Require("Địa chỉ tạm trú"));


            RuleFor(x => x.OriginProvinceCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã tỉnh thường trú"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tỉnh thường trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tỉnh thường trú", 20));


            RuleFor(x => x.OriginDistrictCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã quận/huyện thường trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã quận/huyện thường trú", 20));

            RuleFor(x => x.OriginWardCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phường/xã tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phường/xã tạm trú", 20));

            RuleFor(x => x.OriginAddress).NotEmpty().WithMessage(CommonMessageGlobal.Require("Địa chỉ thường trú"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Địa chỉ thường trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Địa chỉ thường trú", 20));;

            RuleFor(x => x.IdentityNumber).NotEmpty().WithMessage(CommonMessageGlobal.Require("CMND"));

            RuleFor(x => x.PersonalEmail).EmailAddress().WithMessage(CommonMessageGlobal.Invalid("Email cá nhân"));

            RuleFor(x => x.Phone).Matches(@"^(\+\s?)?((?<!\+.*)\(\+?\d+([\s\-\.]?\d+)?\)|\d+)([\s\-\.]?(\(\d+([\s\-\.]?\d+)?\)|\d+))*(\s?(x|ext\.?)\s?\d+)?$").WithMessage(CommonMessageGlobal.Invalid("Số điện thoại"));
        }
Example #18
0
        public CategoryValidator(ICategoryRepository categoryRepository)
        {
            this._categoryRepository = categoryRepository;

            RuleFor(x => x.Id).NotEmpty().WithMessage(CommonMessageGlobal.Require("Id"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Id", 0));

            RuleFor(x => x.Entity).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã Entity"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Entity", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Entity", 20));

            RuleFor(x => x.Name).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên danh mục"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tên danh mục", 2))
            .MaximumLength(256).WithMessage(CommonMessageGlobal.Maximum("Tên danh mục", 256));

            RuleFor(x => x.ParentCode).Must(IsValidParentCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Danh mục cha"));
        }
Example #19
0
        public EmployeeContactDetailValidator()
        {
            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20));

            RuleFor(x => x.FullName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Họ và tên nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Họ và tên nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Họ và tên nhân viên", 256));

            RuleFor(x => x.TemporaryProvinceCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã tỉnh tạm trú"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tỉnh tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tỉnh tạm trú", 20));



            RuleFor(x => x.TemporaryDistrictCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã quận/huyện tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã quận/huyện tạm trú", 20));

            RuleFor(x => x.TemporaryWardCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phường/xã tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phường/xã tạm trú", 20));

            RuleFor(x => x.TemporaryAddress).NotEmpty().WithMessage(CommonMessageGlobal.Require("Địa chỉ tạm trú"));


            RuleFor(x => x.OriginProvinceCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã tỉnh thường trú"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã tỉnh thường trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã tỉnh thường trú", 20));


            RuleFor(x => x.OriginDistrictCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã quận/huyện thường trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã quận/huyện thường trú", 20));

            RuleFor(x => x.OriginWardCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phường/xã tạm trú", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phường/xã tạm trú", 20));

            RuleFor(x => x.OriginAddress).NotEmpty().WithMessage(CommonMessageGlobal.Require("Địa chỉ thường trú"));


            RuleFor(x => x.PersonalEmail).EmailAddress().WithMessage(CommonMessageGlobal.Invalid("Email cá nhân"));

            RuleFor(x => x.CompanyEmail).EmailAddress().WithMessage(CommonMessageGlobal.Invalid("Email công ty"));

            RuleFor(x => x.Phone).Matches(@"^(\+\s?)?((?<!\+.*)\(\+?\d+([\s\-\.]?\d+)?\)|\d+)([\s\-\.]?(\(\d+([\s\-\.]?\d+)?\)|\d+))*(\s?(x|ext\.?)\s?\d+)?$").WithMessage(CommonMessageGlobal.Invalid("Số điện thoại"));
        }
Example #20
0
        public RoleUpdateValidator(IUserRepository userRepository, ICategoryRepository categoryRepository)
        {
            RuleFor(x => x.Id).NotEmpty().WithMessage(CommonMessageGlobal.Require("Id"))
            .GreaterThanOrEqualTo(0).WithMessage(CommonMessageGlobal.GreaterThanOrEqual("Id", 0));

            RuleFor(x => x.Username).NotEmpty().WithMessage(CommonMessageGlobal.Require("Username"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Username", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Username", 50))
            .Must(IsValidUsername).WithMessage(CommonMessageGlobal.NotExistInCategory("Username"));

            RuleFor(x => x.NavigationCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã phân quyền"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phân quyền", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phân quyền", 20))
            .Must(IsValidNavigationCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã phân quyền"));

            RuleFor(x => x.Entity).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Entity", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Entity", 20));
        }
Example #21
0
        public RoleCreateValidator(IUserRepository userRepository, ICategoryRepository categoryRepository)
        {
            this._categoryRepository = categoryRepository;
            this._userRepository     = userRepository;

            RuleFor(x => x.Username).NotEmpty().WithMessage(CommonMessageGlobal.Require("Username"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Username", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Username", 50))
            .Must(IsValidUsername).WithMessage(CommonMessageGlobal.NotExistInCategory("Username"));

            RuleFor(x => x.NavigationCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã phân quyền"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã phân quyền", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã phân quyền", 20))
            .Must(IsValidNavigationCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã phân quyền"));

            RuleFor(x => x.Entity).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Entity", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Entity", 20));
        }
        public ImportEmployeeExcelFileValidator(ICategoryRepository categoryRepository)
        {
            this.categoryRepository = categoryRepository;

            RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"));

            RuleFor(x => x.LastName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tên nhân viên", 20))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Tên nhân viên", 20));

            RuleFor(x => x.FullName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Họ và tên nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Họ và tên nhân viên", 2))
            .MaximumLength(256).WithMessage(CommonMessageGlobal.Maximum("Họ và tên nhân viên", 256));

            RuleFor(x => x.DepartmentCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã bộ phận"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã bộ phận", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã bộ phận", 20))
            .Must(IsValidDepartmentCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã bộ phận"));
        }
Example #23
0
        public EmployeeDayOffValidator(ICategoryRepository categoryRepository)
        {
            this._categoryRepository = categoryRepository;

            RuleFor(x => x.EmployeeCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20));

            RuleFor(x => x.Reason).NotEmpty().WithMessage(CommonMessageGlobal.Require("Lý do nghỉ"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Lý do nghỉ", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Lý do nghỉ", 20))
            .Must(IsValidReasonCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Lý do nghỉ"));


            RuleFor(x => x.ApproveStatus).NotEmpty().WithMessage(CommonMessageGlobal.Require("Trạng thái duyệt"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Trạng thái duyệt", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Trạng thái duyệt", 20))
            .Must(IsValidApproveCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Trạng thái duyệt"));
        }
        public RecruitmentPlanUpdateValidator(ICategoryRepository _categoryRepository)
        {
            categoryRepository = _categoryRepository;

            RuleFor(x => x.Title).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tiêu đề kế hoạch tuyển dụng"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Tiêu đề kế hoạch tuyển dụng", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Tiêu đề kế hoạch tuyển dụng", 100));

            RuleFor(x => x.DepartmentCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã bộ phận"))
            .Must(IsValidDepartmentCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã bộ phận"));

            RuleFor(x => x.JobCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Vị trí công việc"))
            .Must(IsValidJobCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Vị trí công việc"));

            RuleFor(x => x.Status).NotEmpty().WithMessage(CommonMessageGlobal.Require("Trạng thái kế hoạch"))
            .Must(IsValidStatusCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Trạng thái kế hoạch"));

            RuleFor(x => x.Quantity).NotEmpty().WithMessage(CommonMessageGlobal.Require("Số lượng"));
        }
Example #25
0
        public UserCreateValidator(IEmployeeRepository employeeRepository)
        {
            this._employeeRepository = employeeRepository;



            RuleFor(x => x.Username).NotEmpty().WithMessage(CommonMessageGlobal.Require("Username"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Username", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Username", 50));

            RuleFor(x => x.Password).NotEmpty().WithMessage(CommonMessageGlobal.Require("Password"))
            .MinimumLength(4).WithMessage(CommonMessageGlobal.Minimum("Password", 2))
            .MaximumLength(50).WithMessage(CommonMessageGlobal.Maximum("Password", 256));

            RuleFor(x => x.EmployeeCode).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã nhân viên"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã nhân viên", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã nhân viên", 20))
            .Must(IsValidEmployeeCode).WithMessage(CommonMessageGlobal.Invalid("Mã nhân viên"));
        }
Example #26
0
        public EmployeeContractUpdateValidator(IEmployeeContractRepository employeeContractRepository,
                                               IEmployeeRepository employeeRepository)
        {
            this._employeeContractRepository = employeeContractRepository;
            this._employeeRepository         = employeeRepository;

            RuleFor(x => x.SignDate).NotEmpty().WithMessage(CommonMessageGlobal.Require("Ngày ký"));
            RuleFor(x => x.EffectiveDate).NotEmpty().WithMessage(CommonMessageGlobal.Require("Ngày hiệu lực"));

            RuleFor(x => x.CompanySignPerson).NotEmpty().WithMessage(CommonMessageGlobal.Require("Chữ ký công ty"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Chữ ký công ty", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Chữ ký công ty", 20))
            .Must(IsValidEmployeeCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Chữ ký công ty"));

            RuleFor(x => x.EmployeeSignPerson).NotEmpty().WithMessage(CommonMessageGlobal.Require("Chữ ký người lao động"))
            .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Chữ ký người lao động", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Chữ ký người lao động", 20))
            .Must(IsValidEmployeeCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Chữ ký người lao động"));


            RuleFor(x => x.ParentCode).MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã hợp đồng", 2))
            .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã hợp đồng", 20))
            .Must(IsValidNumberCode).WithMessage(CommonMessageGlobal.NotExistInCategory("Mã hợp đồng"));
        }
Example #27
0
        public ActionResult <CommonResponeModel> CheckFileEmployees([FromForm] IFormFile file)
        {
            if (file == null || string.IsNullOrWhiteSpace(file.FileName))
            {
                Result = new ErrorResult(ActionType.CheckFileExcel, CommonMessageGlobal.Require("File Excel"));
                return(GetCommonRespone());
            }

            try
            {
                string path         = Path.Combine(AppGlobal.ExcelImportDestFolder, DateTime.Now.ToString("yyyyMMddHHmmss") + file.FileName);
                string pathXmlCheck = Path.Combine(AppGlobal.XmlTemplateImportFolder, "Employee.xml");

                //save file to server
                file.SaveTo(path);

                //read file to check
                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                using (var stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read))
                {
                    using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
                    {
                        var dataSet = reader.AsDataSet(new ExcelDataSetConfiguration
                        {
                            ConfigureDataTable = _ => new ExcelDataTableConfiguration
                            {
                                UseHeaderRow = true // Use first row is ColumnName here
                            }
                        });

                        if (dataSet.Tables.Count > 0)
                        {
                            SheetTemplateImport templateImport = new SheetTemplateImport(pathXmlCheck);

                            DataTable table = dataSet.Tables[templateImport.SheetName];

                            foreach (var column in templateImport.Columns)
                            {
                                if (!string.IsNullOrWhiteSpace(column.excelHeader))
                                {
                                    table.Columns[column.excelHeader].ColumnName = column.propertyName;
                                }
                            }

                            //validate data
                            var validator = new ImportEmployeeExcelFileValidator(categoryRepository);
                            List <EmployeeImportDataTransfer> employees = table.ToList <EmployeeImportDataTransfer>(true);
                            foreach (var employee in employees)
                            {
                                ValidationResult results = validator.Validate(employee);

                                if (!results.IsValid)
                                {
                                    foreach (var failure in results.Errors)
                                    {
                                        employee.IsError = true;
                                        employee.ErrorMessage.Add(failure.ErrorMessage);
                                    }
                                }
                            }

                            Data = employees;
                        }
                    }
                }

                Result = new SuccessResultFactory().Factory(ActionType.CheckFileExcel);
            }
            catch (Exception)
            {
                Result = new ErrorResultFactory().Factory(ActionType.CheckFileExcel);
            }

            return(GetCommonRespone());
        }
Example #28
0
 public RoleGroupCreateValidator()
 {
     RuleFor(x => x.Code).NotEmpty().WithMessage(CommonMessageGlobal.Require("Mã"))
     .MinimumLength(2).WithMessage(CommonMessageGlobal.Minimum("Mã", 2))
     .MaximumLength(20).WithMessage(CommonMessageGlobal.Maximum("Mã", 20));
 }
Example #29
0
 public ContractTypeCreateValidator()
 {
     RuleFor(x => x.TextName).NotEmpty().WithMessage(CommonMessageGlobal.Require("Tên loại hợp đồng"));
     RuleFor(x => x.TemplatePath).NotEmpty().WithMessage(CommonMessageGlobal.Require("Đường dẫn "));
 }
Example #30
0
        public ActionResult <CommonResponeModel> SaveChange([FromForm] EmployeeSaveChangeRequestModel model)
        {
            var databaseObject = new Employee();
            int result;

            if (model.Id == 0)
            {
                databaseObject.MapFrom(model);

                if (string.IsNullOrEmpty(databaseObject.Code))
                {
                    var code = entityCenterRepository.GetCodeByEntity(nameof(Employee));

                    if (string.IsNullOrEmpty(code))
                    {
                        Result = new ErrorResult(ActionType.Insert, AppGlobal.MakeCodeError);
                        return(GetCommonRespone());
                    }

                    databaseObject.Code = code;
                }

                if (employeeRepository.IsExistCode(databaseObject.Code))
                {
                    Result = new ErrorResult(ActionType.Insert, CommonMessageGlobal.Exist("Mã nhân viên"));
                    return(GetCommonRespone());
                }

                databaseObject.InitBeforeSave(RequestUsername, InitType.Create);
                databaseObject.InitDefault();

                //lưu hình nếu tồn tại
                if (model.ImageFile != null && string.IsNullOrWhiteSpace(model.ImageFile.FileName))
                {
                    model.ImageFile.SaveTo(AppGlobal.AvatarFolder);
                    databaseObject.Image = Path.Combine(AppGlobal.AvatarFolder, model.ImageFile.FileName);
                }

                result = employeeRepository.Insert(databaseObject);
            }
            else
            {
                databaseObject = employeeRepository.GetById(model.Id);
                databaseObject.MapFrom(model);
                databaseObject.InitBeforeSave(RequestUsername, InitType.Update);
                databaseObject.InitDefault();

                //lưu hình nếu tồn tại
                if (model.ImageFile != null && !string.IsNullOrWhiteSpace(model.ImageFile.FileName))
                {
                    var pathFolder = $@"\Storages\Avatars";
                    var folder     = this._env.WebRootPath + pathFolder;
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }

                    string filePath = Path.Combine(folder, model.ImageFile.FileName);
                    using (FileStream fs = System.IO.File.Create(filePath))
                    {
                        model.ImageFile.CopyTo(fs);
                        fs.Flush();
                    }

                    databaseObject.Image = Path.Combine(pathFolder, model.ImageFile.FileName).Replace(@"\", @"/");
                }

                result = employeeRepository.Update(databaseObject);
            }

            if (result > 0)
            {
                Result = new SuccessResult(ActionType.Insert, AppGlobal.SaveChangeSuccess);
            }
            else
            {
                Result = new ErrorResult(ActionType.Insert, AppGlobal.SaveChangeFalse);
            }

            return(GetCommonRespone());
        }