public ActionResult UploadFile_StudentInfoTimeIntervalValide(DayAndNightAddViewModel dayAndNightAddViewModel) { FileUploadViewModel fileUploadViewModel = new FileUploadViewModel(); var files = Request.Form.Files; String filePath = "";//上传文件的路径 if (files.Count == 0) { throw new ArgumentException("找不到上传的文件"); } var result = _fileService.InputStudentInfoTimeIntervalIntoDataBaseValide(dayAndNightAddViewModel); return(Ok("未找到文件")); }
public DayAndNightStudentImportResModel InputStudentInfoTimeIntervalIntoDataBaseValide(DayAndNightAddViewModel dayAndNightAddViewModel) { DayAndNightStudentImportResModel dayAndNightStudentImportResModel = new DayAndNightStudentImportResModel(); var insetlist = _IMapper.Map <List <DayAndNightAddMiddle>, List <Student_DayandNight_Info> >(dayAndNightAddViewModel.dayAndNightAddMiddles); var errorinfo = _valideService.ValideListDayAndNight <Student_DayandNight_Info>(insetlist, dayAndNightAddViewModel.idNumber); errorinfo = _valideService.ValideListDayAndNightOverRall <Student_DayandNight_Info>(insetlist, dayAndNightAddViewModel.idNumber, errorinfo); errorinfo = _valideService.ValideListDayAndNightNum <Student_DayandNight_Info>(insetlist, dayAndNightAddViewModel.idNumber, errorinfo); errorinfo = _valideService.ValideListDayAndNightNumIdInClass <Student_DayandNight_Info>(insetlist, errorinfo); if (errorinfo.Length == 0) { dayAndNightStudentImportResModel.IsSuccess = true; dayAndNightStudentImportResModel.StringBuilder.Append("数据格式正确"); _dayandNightRepository.AddList(insetlist); _dayandNightRepository.SaveChanges(); return(dayAndNightStudentImportResModel); } else { dayAndNightStudentImportResModel.IsSuccess = false; dayAndNightStudentImportResModel.StringBuilder = errorinfo; return(dayAndNightStudentImportResModel); } }