Untitled

 avatar
unknown
plain_text
a month ago
3.6 kB
2
Indexable
 case "MAD":
                            Constants.Upload.FileValidationDelegate<TimelogUploadTXTViewModel> validationDelegateMADTXT =
                             new TimelogsHandler(_timelogsService,
                                                 _userMasterService,
                                                 _employeeService,
                                                 _accessLevelMasterService)
                                                 .VerifyExtractedTimecardPayrollDataTXTMAD;

                            var txtReaderViewModelMAD = await Helper.ReadFile(provider,
                                                                             Constants.Timelogs.TimelogsModulePayrollName,
                                                                             validationDelegateMADTXT,
                                                                             null,
                                                                             false,
                                                                             true,
                                                                             user,
                                                                             _employeeService,
                                                                             biometricFormatValue,
                                                                             _timelogsService);

                            var validateErrorsTxTMAD = txtReaderViewModelMAD.FailedReadLines
                                           .Select(x => new ValidationResult(x))
                                           .ToList();

                            var validateNewModelsTxtMAD = new TimelogsHandler(_timelogsService,
                                                                            _userMasterService,
                                                                            _employeeService,
                                                                            _accessLevelMasterService)
                                                                            .CanImportToPayrollTXTSSP(txtReaderViewModelMAD.SucceededReadLines);

                            validateErrorsTxTMAD.AddRange(validateNewModelsTxtMAD.FailedReadLines);

                            if (validateNewModelsTxtMAD.SucceededReadLines.Count > 0)
                            {
                                var timelogsList = validateNewModelsTxtMAD.SucceededReadLines;
                                _timelogsService.BulkCreateTxt(timelogsList, companySetup);
                                responseData.Status = true;
                                responseData.Message = Constants.Upload.UploadSuccess;
                            }
                            else
                            {
                                responseData.Status = false;
                                responseData.Message = Constants.Upload.UploadFail;
                            }

                            if (validateNewModelsTxtMAD.FailedReadLines.Count > 0 || validateErrorsTxTMAD.Count > 0)
                            {
                                responseData.Data = new
                                {
                                    hasValidationErrors = true,
                                    validationErrors = validateErrorsTxTMAD.Select(x => x.Message).ToArray(),
                                };
                            }

                            break;
Leave a Comment