Exemplo n.º 1
0
        public ActionResult <CommonResponeModel> Delete(long Id)
        {
            int result = trainingCourseEmployeeRepository.Delete(Id);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Delete);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Delete);
            }

            return(GetCommonRespone());
        }
Exemplo n.º 2
0
        public ActionResult <CommonResponeModel> DeleteByCode(string Code)
        {
            int result = categoryRepository.Delete(Code);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Delete);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Delete);
            }

            return(GetCommonRespone());
        }
        public ActionResult <CommonResponeModel> Delete(long Id)
        {
            int result = recruitmentPlanRepository.Delete(Id);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Delete);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Delete);
            }

            return(GetCommonRespone());
        }
Exemplo n.º 4
0
        public ActionResult <CommonResponeModel> Update(ShiftUpdateRequestModel model)
        {
            var databaseObject = model.MapTo <Shift>();

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);
            int result = shiftRepository.Update(databaseObject);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Edit);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Edit);
            }
            return(GetCommonRespone());
        }
        public ActionResult <CommonResponeModel> Create(RecruitmentPlanCreateRequestModel model)
        {
            var validator = new RecruitmentPlanCreateValidator(categoryRepository);

            var databaseObject = model.MapTo <RecruitmentPlan>();

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

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

                databaseObject.Code = code;
            }

            //check exist in db
            if (recruitmentPlanRepository.IsExistCode(databaseObject.Code))
            {
                Result = new ErrorResult(ActionType.Insert, AppGlobal.ExistCodeError);
                return(GetCommonRespone());
            }

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);

            int result = recruitmentPlanRepository.Insert(databaseObject);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Insert);
                Data   = databaseObject;
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Insert);
                Data   = databaseObject;
            }

            return(GetCommonRespone());
        }
Exemplo n.º 6
0
        public ActionResult <CommonResponeModel> Create(TrainingCourseEmployeeCreateRequestModel model)
        {
            var databaseObject = model.MapTo <TrainingCourseEmployee>();

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);
            int result = trainingCourseEmployeeRepository.Insert(databaseObject);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Insert);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Insert);
            }

            return(GetCommonRespone());
        }
        public ActionResult <CommonResponeModel> Create(CandidatePaperCreateRequestModel model)
        {
            var databaseObject = model.MapTo <CandidatePaper>();

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

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

                databaseObject.Code = code;
            }

            //check exist in db
            if (candidatePaperRepository.IsExistCode(databaseObject.Code))
            {
                Result = new ErrorResult(ActionType.Insert, AppGlobal.ExistCodeError);
                return(GetCommonRespone());
            }

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);
            int result = candidatePaperRepository.Insert(databaseObject);

            //result
            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Insert);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Insert);
            }

            return(GetCommonRespone());
        }
Exemplo n.º 8
0
        public ActionResult <CommonResponeModel> Create(Navigation model)
        {
            //empty code
            if (string.IsNullOrEmpty(model.Code))
            {
                var code = entityCenterRepository.GetCodeByEntity(nameof(Navigation));

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

                model.Code = code;
            }

            //check exist in db
            if (navigationRepository.IsExistCode(model.Code))
            {
                Result = new ErrorResult(ActionType.Insert, AppGlobal.ExistCodeError);
                return(GetCommonRespone());
            }

            model.InitBeforeSave(RequestUsername, InitType.Create);
            model.InitDefault();
            int result = navigationRepository.Insert(model, out model);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Insert);
                Data   = model;
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Insert);
                Data   = model;
            }

            return(GetCommonRespone());
        }
Exemplo n.º 9
0
        public ActionResult <CommonResponeModel> Create(CandidateCreateRequestModel model)
        {
            var databaseObject = model.MapTo <Candidate>();

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);

            if (string.IsNullOrEmpty(databaseObject.Code))
            {
                var code = this._entityCenterRepository.GetCodeByEntity(nameof(Candidate));

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

                databaseObject.Code = code;
            }

            if (this._candidateRepository.GetByCode(databaseObject.Code) != null)
            {
                Result = new ErrorResult(ActionType.Insert, AppGlobal.ExistCodeError);
                return(GetCommonRespone());
            }

            int result = this._candidateRepository.Insert(databaseObject);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Insert);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Insert);
            }

            return(GetCommonRespone());
        }
Exemplo n.º 10
0
        public ActionResult <CommonResponeModel> Login(LoginUserRequestModel model)
        {
            var LoginResponeModel = new LoginResponeModel();

            //login success
            if (userRepository.IsValidUser(model.Username, model.Password))
            {
                Result = new SuccessResultFactory().Factory(ActionType.Login);

                LoginResponeModel.TokenExpireDate = DateTime.Now.AddDays(1);
                LoginResponeModel.Token           = TokenProvider.GenerateTokenString(model.ToDictionaryStringString());
                LoginResponeModel.User            = userRepository.GetDataTransferByUsername(model.Username);
            }
            else //login fail
            {
                Result = new ErrorResultFactory().Factory(ActionType.Login);
            }

            //set data
            Data = LoginResponeModel;

            return(GetCommonRespone());
        }
Exemplo n.º 11
0
        public ActionResult <CommonResponeModel> Update(Navigation model)
        {
            model.InitBeforeSave(RequestUsername, InitType.Update);
            model.InitDefault();

            var existModel = navigationRepository.GetById(model.Id);

            ObjectExtensions.CopyValues(existModel, model);

            int result = navigationRepository.Update(existModel, out existModel);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Edit);
                Data   = existModel;
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Edit);
                Data   = existModel;
            }

            return(GetCommonRespone());
        }
Exemplo n.º 12
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());
        }