public IEnumerable <SchoolProgressView> GetSchoolProgress(string dataSignId) { var term = new TermAppl().GetMaxTerm(); //取教学任务 //因数据库中的学院或系教研室可能为空,所以入口为学院而不是教学任务 var teachingTasks = _schoolRepo.GetAll() .SelectMany(t => t.Departments ).SelectMany(t => t.TeachingTasks ).Where(t => t.SchoolYearTerm.Year == term.SchoolYearTerm.Year && t.SchoolYearTerm.Term == term.SchoolYearTerm.Term && t.DataSign_Id == dataSignId ); //创建学院进度 //var result = Domain.DeclarationService.CreateSchoolProgress(teachingTasks); var result = new List <SchoolProgress>(); //按学院名称排序 result = result.OrderByDescending(t => t.School.Name).ToList(); return(_adapter.Adapt <SchoolProgressView>(result)); }
public IEnumerable<SchoolProgressView> GetSchoolProgress(string dataSignId) { var term = new TermAppl().GetMaxTerm(); //取教学任务 //因数据库中的学院或系教研室可能为空,所以入口为学院而不是教学任务 var teachingTasks = _schoolRepo.GetAll() .SelectMany(t => t.Departments ).SelectMany(t => t.TeachingTasks ).Where(t => t.SchoolYearTerm.Year == term.SchoolYearTerm.Year && t.SchoolYearTerm.Term == term.SchoolYearTerm.Term && t.DataSign_Id == dataSignId ); //创建学院进度 //var result = Domain.DeclarationService.CreateSchoolProgress(teachingTasks); var result = new List<SchoolProgress>(); //按学院名称排序 result = result.OrderByDescending(t => t.School.Name).ToList(); return _adapter.Adapt<SchoolProgressView>(result); }
/// <summary> /// 根据登录名取学院 /// </summary> /// <param name="loginName"></param> /// <returns></returns> public IEnumerable<School> GetSchoolByLoginName(string loginName) { //登录名取书商ID var booksellerId = new TbmisUserAppl(loginName).GetUser().SchoolId; //取当前学期 var term = new TermAppl().GetCurrentTerm().SchoolYearTerm; //取学生用书申报的ID集合 var declarations = _repo.First(t => t.ID == booksellerId ).Subscriptions.Where(t => t.SchoolYearTerm.Year == term.Year && t.SchoolYearTerm.Term == term.Term && t.FeedbackState == FeedbackState.征订成功 && t.Feedback.ApprovalState == ApprovalState.终审通过 ).SelectMany(t => t.StudentDeclarations ).Select(t => t.ID ); //取学生班级 var repo = ServiceLocator.Current.GetInstance<IStudentDeclarationRepository>(); //取学院 var schools = new List<School>(); foreach (var item in declarations) { var schoolsOfDeclaration = repo.GetSchools(item).ToList(); if (schoolsOfDeclaration.Count > 0) schools.Concat(schoolsOfDeclaration); } return schools.Distinct(); }
public ResponseView SubmitTeacherDeclaration(DeclarationView view) { //类型转换 var textId = view.TextbookId.ConvertToGuid(); var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId; var count = view.DeclarationCount.ConvertToInt(); //当前学期 var term = new TermAppl().GetMaxTerm().YearTerm; //操作响应类 var result = new ResponseView(); try { ////CUD仓储 //var repo = ServiceLocator.Current.GetInstance<ITeacherDeclarationRepository>(); ////创建申报 //var declaration = Domain.DeclarationService.CreateDeclaration<TeacherDeclaration>(term, view.TeachingTaskNums.First(), textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook); ////保存 //repo.Add(declaration); ////提交到数据库 //repo.Context.Commit(); return(result); } catch (Exception e) { result.IsSuccess = false; result.Message = "提交教师用书申报失败"; return(result); } }
public IEnumerable<DeclarationForApprovalView> GetDeclarationWithNotApproval(string loginName, string schoolId) { //登录用户 var webUser = new TbmisUserAppl(loginName).GetUser(); //最大学期 var term = new TermAppl().GetMaxTerm().YearTerm; var id = schoolId.ConvertToGuid(); IEnumerable<DeclarationJiaoWu> declarations = new List<DeclarationJiaoWu>(); ////如果是教务处或教材科,取全部 //if (webUser.IsInRole("教务处")) //{ // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教务处审核中 && // t.TeachingTask.Department.School_Id == id // ); //} //else if (webUser.IsInRole("教材科")) //{ // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教材科审核中 && // t.TeachingTask.Department.School_Id == id // ); //} ////如果是学院院长,返回所属学院 //else if (webUser.IsInRole("学院院长")) //{ // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.学院审核中 && // t.TeachingTask.Department.School_Id == id // ); //} ////如果是教研室主任,返回所属系教研室未审核记录 //else if (webUser.IsInRole("教研室主任")) //{ // //取登录用户所属教研室ID // var ids = new DepartmentAppl().GetDepartmentBySchoolId(loginName, id).Select(t => t.DepartmentId); // //取上述教研室申报的未审核用书 // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教研室审核中 && // ids.Contains(t.TeachingTask.Department.DepartmentId)); //} //结果处理 if (declarations.Count() > 0) { return _adapter.Adapt<DeclarationForApprovalView>(declarations); } else { return new List<DeclarationForApprovalView>(); } }
public IEnumerable <DeclarationForApprovalView> GetDeclarationWithNotApproval(string loginName, string schoolId) { //登录用户 var webUser = new TbmisUserAppl(loginName).GetUser(); //最大学期 var term = new TermAppl().GetMaxTerm().YearTerm; var id = schoolId.ConvertToGuid(); IEnumerable <DeclarationJiaoWu> declarations = new List <DeclarationJiaoWu>(); ////如果是教务处或教材科,取全部 //if (webUser.IsInRole("教务处")) //{ // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教务处审核中 && // t.TeachingTask.Department.School_Id == id // ); //} //else if (webUser.IsInRole("教材科")) //{ // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教材科审核中 && // t.TeachingTask.Department.School_Id == id // ); //} ////如果是学院院长,返回所属学院 //else if (webUser.IsInRole("学院院长")) //{ // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.学院审核中 && // t.TeachingTask.Department.School_Id == id // ); //} ////如果是教研室主任,返回所属系教研室未审核记录 //else if (webUser.IsInRole("教研室主任")) //{ // //取登录用户所属教研室ID // var ids = new DepartmentAppl().GetDepartmentBySchoolId(loginName, id).Select(t => t.DepartmentId); // //取上述教研室申报的未审核用书 // declarations = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教研室审核中 && // ids.Contains(t.TeachingTask.Department.DepartmentId)); //} //结果处理 if (declarations.Count() > 0) { return(_adapter.Adapt <DeclarationForApprovalView>(declarations)); } else { return(new List <DeclarationForApprovalView>()); } }
public IEnumerable <TermView> GetTerm() { var terms = new TermAppl().GetAll(); //排序 terms = terms.OrderByDescending(t => t.YearTerm); return(_adapter.Adapt <TermView>(terms)); }
public IEnumerable<CourseView> GetCourseByDepartmentId(string departmentId) { var id = departmentId.ConvertToGuid(); //取最大学年学期 var term = new TermAppl().GetMaxTerm(); var courses = new CourseAppl().GetCourseByDepartmentId(id, term.YearTerm); courses = courses.OrderBy(t => t.Num); return _adapter.Adapt<CourseView>(courses); }
public IEnumerable <CourseView> GetCourseByDepartmentId(string departmentId) { var id = departmentId.ConvertToGuid(); //取最大学年学期 var term = new TermAppl().GetMaxTerm(); var courses = new CourseAppl().GetCourseByDepartmentId(id, term.YearTerm); courses = courses.OrderBy(t => t.Num); return(_adapter.Adapt <CourseView>(courses)); }
public IEnumerable <SchoolView> GetSchoolWithNotApproval(string loginName) { //系统用户 var user = new TbmisUserAppl(loginName).GetUser(); //最大学期 var term = new TermAppl().GetMaxTerm().YearTerm; IList <School> schools = new List <School>(); ////如果是教务处或教材科,取全部学院 //if (user.IsInRole("教务处")) //{ // var school = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教务处审核中 // ).Select(t => // t.TeachingTask.Department.School // ).Distinct(); // schools = school.ToList(); //} //else if (user.IsInRole("教材科")) //{ // var school = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教材科审核中 // ).Select(t => // t.TeachingTask.Department.School // ).Distinct(); // schools = school.ToList(); //} ////如果是学院院长,返回所属学院 //else if (user.IsInRole("学院院长") || user.IsInRole("教研室主任")) //{ // var school = new School { SchoolId = (Guid)user.SchoolId, Name = user.SchoolName }; // schools.Add(school); //} if (schools.Count > 0) { return(_adapter.Adapt <SchoolView>(schools)); } else { IEnumerable <SchoolView> school = new List <SchoolView> { new SchoolView { SchoolId = string.Empty, Name = "没有需要审核的学院" } }; return(school); } }
public IEnumerable <TeachingTaskView> GetTeachingTaskByDepartmentId(string departmentId, string courseId) { //取最大学期 var term = new TermAppl().GetMaxTerm(); //数据类型转换 var depaId = departmentId.ConvertToGuid(); var courId = courseId.ConvertToGuid(); var teachingTask = _teachingTaskRepo.Find(t => t.SchoolYearTerm.Year == term.SchoolYearTerm.Year && t.SchoolYearTerm.Term == term.SchoolYearTerm.Term && t.Department_Id == depaId && t.Course_Id == courId ); //转ViewModel teachingTask = teachingTask.OrderBy(t => t.TeachingTaskNum); return(_adapter.Adapt <TeachingTaskView>(teachingTask)); }
/// <summary> /// 由系教研室ID与学期 /// 取课程 /// </summary> /// <param name="departmentId"></param> /// <param name="term"></param> /// <returns></returns> public IEnumerable <Course> GetCourseByDepartmentId(Guid departmentId, string term) { var currentTerm = new SchoolYearTerm(term); //处理学期,为空则取当前学期 if (string.IsNullOrWhiteSpace(term)) { var yearTerm = new TermAppl().GetCurrentTerm().YearTerm; currentTerm = new SchoolYearTerm(yearTerm); } //构造学年学期,与教务匹配 var courses = _teachingTaskRepo.Find(t => t.SchoolYearTerm.Year == currentTerm.Year && t.SchoolYearTerm.Term == currentTerm.Term && t.Department_Id == departmentId ).Select(t => t.Course ).Distinct(); return(courses); }
/// <summary> /// 由系教研室ID与学期 /// 取课程 /// </summary> /// <param name="departmentId"></param> /// <param name="term"></param> /// <returns></returns> public IEnumerable<Course> GetCourseByDepartmentId(Guid departmentId, string term) { var currentTerm = new SchoolYearTerm(term); //处理学期,为空则取当前学期 if (string.IsNullOrWhiteSpace(term)) { var yearTerm = new TermAppl().GetCurrentTerm().YearTerm; currentTerm = new SchoolYearTerm(yearTerm); } //构造学年学期,与教务匹配 var courses = _teachingTaskRepo.Find(t => t.SchoolYearTerm.Year == currentTerm.Year && t.SchoolYearTerm.Term == currentTerm.Term && t.Department_Id == departmentId ).Select(t => t.Course ).Distinct(); return courses; }
public IEnumerable<DepartmentProgressView> GetDepartmentProgress(string dataSignId, string departmentId) { //取最大学期 var term = new TermAppl().GetMaxTerm(); var id = departmentId.ConvertToGuid(); //取教学任务 //因数据库中的学院或系教研室可能为空,所以入口为学院而不是教学任务 var teachingTasks = _departRepo.First(t => t.ID == id ).TeachingTasks .Where(t => t.SchoolYearTerm.Year == term.SchoolYearTerm.Year && t.SchoolYearTerm.Term == term.SchoolYearTerm.Term && t.DataSign_Id == dataSignId ); //创建系教研室进度 //var result = Domain.DeclarationService.CreateDepartmentProgress(teachingTasks); var result = new List<DepartmentProgress>(); //按课程名称排序 result = result.OrderBy<DepartmentProgress, string>(t => t.Course.Name).ToList(); return _adapter.Adapt<DepartmentProgressView>(result); }
/// <summary> /// 根据学生ID,取学生可退还教材 /// </summary> /// <param name="studentId"></param> /// <returns></returns> public IEnumerable <DropBookForStudentQueryView> GetStudentDropBookByStudentId(string studentId) { var sId = studentId.ConvertToGuid(); var currentTerm = new TermAppl().GetCurrentTerm(); var dropStudentBook = _studentReleaseRecordRepo.Find(s => s.Student_Id == sId && s.SchoolYearTerm.Year == currentTerm.SchoolYearTerm.Year && s.SchoolYearTerm.Term == currentTerm.SchoolYearTerm.Term ).Select(s => new { YearTerm = s.SchoolYearTerm, TextbookName = s.Name, TextbookId = s.Textbook_Id, ReleaseCount = s.ReleaseCount, ReleaseDate = s.ReleaseDate, ReleasePerson = s.OutStockRecord.Operator, RecipientName = s.Recipient1Name, RecipientTelephone = s.Recipient1Phone, ReleaseRecordId = s.ID }); return(_typeAdapter.Adapt <DropBookForStudentQueryView>(dropStudentBook)); }
/// <summary> /// 根据登录名取学院 /// </summary> /// <param name="loginName"></param> /// <returns></returns> public IEnumerable <School> GetSchoolByLoginName(string loginName) { //登录名取书商ID var booksellerId = new TbmisUserAppl(loginName).GetUser().SchoolId; //取当前学期 var term = new TermAppl().GetCurrentTerm().SchoolYearTerm; //取学生用书申报的ID集合 var declarations = _repo.First(t => t.ID == booksellerId ).Subscriptions.Where(t => t.SchoolYearTerm.Year == term.Year && t.SchoolYearTerm.Term == term.Term && t.FeedbackState == FeedbackState.征订成功 && t.Feedback.ApprovalState == ApprovalState.终审通过 ).SelectMany(t => t.StudentDeclarations ).Select(t => t.ID ); //取学生班级 var repo = ServiceLocator.Current.GetInstance <IStudentDeclarationRepository>(); //取学院 var schools = new List <School>(); foreach (var item in declarations) { var schoolsOfDeclaration = repo.GetSchools(item).ToList(); if (schoolsOfDeclaration.Count > 0) { schools.Concat(schoolsOfDeclaration); } } return(schools.Distinct()); }
public IEnumerable <DepartmentProgressView> GetDepartmentProgress(string dataSignId, string departmentId) { //取最大学期 var term = new TermAppl().GetMaxTerm(); var id = departmentId.ConvertToGuid(); //取教学任务 //因数据库中的学院或系教研室可能为空,所以入口为学院而不是教学任务 var teachingTasks = _departRepo.First(t => t.ID == id ).TeachingTasks .Where(t => t.SchoolYearTerm.Year == term.SchoolYearTerm.Year && t.SchoolYearTerm.Term == term.SchoolYearTerm.Term && t.DataSign_Id == dataSignId ); //创建系教研室进度 //var result = Domain.DeclarationService.CreateDepartmentProgress(teachingTasks); var result = new List <DepartmentProgress>(); //按课程名称排序 result = result.OrderBy <DepartmentProgress, string>(t => t.Course.Name).ToList(); return(_adapter.Adapt <DepartmentProgressView>(result)); }
/// <summary> /// 退还班级教材 /// </summary> /// <param name="classId"></param> /// <param name="releaseRecordIds"></param> /// <returns></returns> public ResponseView DropClassBookSubmit(string classId, IEnumerable <string> releaseRecordIds) { //数据类型转换 Guid cId = classId.ConvertToGuid(); var term = new TermAppl().GetCurrentTerm().ToString(); //根据发放记录Id,当前学期,取该班级每本教材的退还数 var dorpBookCountForClass = new List <Domain.Models.StudentReleaseRecord>(); foreach (string recordId in releaseRecordIds) { var rId = recordId.ConvertToGuid(); var classRel = _studentReleaseRecordRepo.Find(s => s.Class_Id == cId && s.ID == rId).GroupBy(s => new { s.Textbook_Id, s.ID }).Select(d => new StudentReleaseRecord() { ID = d.Key.ID, Textbook_Id = d.Key.Textbook_Id, ReleaseCount = d.Sum(s => s.ReleaseCount) }); dorpBookCountForClass.AddRange(classRel); } //根据发放记录Id,取对应的库存变更记录Id var stockRecordIds = new List <Domain.Models.StudentReleaseRecord>(); foreach (string releaseRecordId in releaseRecordIds) { var recordId = releaseRecordId.ConvertToGuid(); var stockRecordId = _studentReleaseRecordRepo.First(s => s.ID == recordId); stockRecordIds.Add(stockRecordId); } //根据库存变更记录Id,取库存Id var inventoryIds = new List <Domain.Models.InStockRecord>(); foreach (StudentReleaseRecord id in stockRecordIds) { var inventoryId = _inStockRecordRepo.First(i => i.ID == id.StockRecord_Id); inventoryIds.Add(inventoryId); } var result = new ResponseView(); var message = string.Empty; var messageForResponse = string.Empty; var releaseRecordCount = 0; releaseRecordCount += releaseRecordIds.Count(); var successCount = 0; //删除库存变记录 foreach (Domain.Models.StudentReleaseRecord stockRecordId in stockRecordIds) { if (stockRecordId.StockRecord_Id != null) { var stoockRecord = Domain.ReleaseBookService.CreateStockRecord(stockRecordId.StockRecord_Id.Value); _inStockRecordRepo.Remove(stoockRecord); _inStockRecordRepo.Context.Commit(); } } //修改库存数量 foreach (InStockRecord view in inventoryIds) { var releaseCount = dorpBookCountForClass.First(d => d.StockRecord_Id == view.ID).ReleaseCount; var inventory = Domain.ReleaseBookService.CreatInventoryAtDrop(view.Inventory_Id, releaseCount); _inventoryRepo.Modify(inventory); _inventoryRepo.Context.Commit(); } //删除班级发放记录 foreach (string releaseRecordId in releaseRecordIds) { var claID = classId.ConvertToGuid(); var studentRecord = Domain.ReleaseBookService.CreateClassDropReleaseRecord( releaseRecordId.ConvertToGuid(), claID); _studentReleaseRecordRepo.Remove(studentRecord); _studentReleaseRecordRepo.Context.Commit(); successCount++; } return(result); }
public IEnumerable<SchoolView> GetSchoolWithNotApproval(string loginName) { //系统用户 var user = new TbmisUserAppl(loginName).GetUser(); //最大学期 var term = new TermAppl().GetMaxTerm().YearTerm; IList<School> schools = new List<School>(); ////如果是教务处或教材科,取全部学院 //if (user.IsInRole("教务处")) //{ // var school = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教务处审核中 // ).Select(t => // t.TeachingTask.Department.School // ).Distinct(); // schools = school.ToList(); //} //else if (user.IsInRole("教材科")) //{ // var school = _declRepo.Find(t => // t.Term == term && // t.ApprovalState == ApprovalState.教材科审核中 // ).Select(t => // t.TeachingTask.Department.School // ).Distinct(); // schools = school.ToList(); //} ////如果是学院院长,返回所属学院 //else if (user.IsInRole("学院院长") || user.IsInRole("教研室主任")) //{ // var school = new School { SchoolId = (Guid)user.SchoolId, Name = user.SchoolName }; // schools.Add(school); //} if (schools.Count > 0) { return _adapter.Adapt<SchoolView>(schools); } else { IEnumerable<SchoolView> school = new List<SchoolView> { new SchoolView { SchoolId = string.Empty, Name = "没有需要审核的学院" } }; return school; } }
/// <summary> /// 退还学生教材 /// </summary> /// <param name="releaseRecordeIds"></param> /// <param name="studentId"></param> /// <returns></returns> public ResponseView DropStudenBookSubmit(IEnumerable <string> releaseRecordeIds, string studentId) { //数据类型转换 Guid stID = studentId.ConvertToGuid(); var term = new TermAppl().GetCurrentTerm().ToString(); //根据学生Id,发放记录Id,取该生每本教材的退还数 var dorpBookCountForStudent = new List <StudentReleaseRecord>(); foreach (string recordId in releaseRecordeIds) { var rId = recordId.ConvertToGuid(); var studentRel = _studentReleaseRecordRepo.First(s => s.Student_Id == stID && s.ID == rId); dorpBookCountForStudent.Add(studentRel); } //根据发放记录Id,取对应的库存变更记录Id var stockRecordIds = new List <StudentReleaseRecord>(); foreach (string recordId in releaseRecordeIds) { var rId = recordId.ConvertToGuid(); var stockRecordId = _studentReleaseRecordRepo.First(s => s.ID == rId); stockRecordIds.Add(stockRecordId); } //根据库存变更记录Id,取库存Id var inventoryIds = new List <Domain.Models.InStockRecord>(); foreach (StudentReleaseRecord id in stockRecordIds) { var inventoryId = _inStockRecordRepo.First(i => i.ID == id.StockRecord_Id); inventoryIds.Add(inventoryId); } var result = new ResponseView(); var message = string.Empty; var messageForResponse = string.Empty; var releaseRecordCount = 0; releaseRecordCount += dorpBookCountForStudent.Count(); var successCount = 0; //删除库存变记录 foreach (StudentReleaseRecord stockRecordId in stockRecordIds) { if (stockRecordId.StockRecord_Id != null) { var stoockRecord = Domain.ReleaseBookService.CreateStockRecord(stockRecordId.StockRecord_Id.Value); _inStockRecordRepo.Remove(stoockRecord); _inStockRecordRepo.Context.Commit(); } } //修改库存数量 foreach (InStockRecord view in inventoryIds) { var releaseCount = dorpBookCountForStudent.First(d => d.StockRecord_Id == view.ID).ReleaseCount; var inventory = Domain.ReleaseBookService.CreatInventoryAtDrop(view.Inventory_Id, releaseCount); _inventoryRepo.Modify(inventory); _inventoryRepo.Context.Commit(); } //删除学生发放记录 foreach (StudentReleaseRecord view in dorpBookCountForStudent) { var studentRecord = Domain.ReleaseBookService.CreateStudentDropReleaseRecord( view.ID, stID); _studentReleaseRecordRepo.Remove(studentRecord); _studentReleaseRecordRepo.Context.Commit(); successCount++; } return(result); }
public void GetMaxTerm() { var app = new TermAppl(); var term = app.GetMaxTerm(); Assert.AreSame("2011-2012-2", term.YearTerm); }
public IEnumerable<TeachingTaskView> GetTeachingTaskByDepartmentId(string departmentId, string courseId) { //取最大学期 var term = new TermAppl().GetMaxTerm(); //数据类型转换 var depaId = departmentId.ConvertToGuid(); var courId = courseId.ConvertToGuid(); var teachingTask = _teachingTaskRepo.Find(t => t.SchoolYearTerm.Year == term.SchoolYearTerm.Year && t.SchoolYearTerm.Term == term.SchoolYearTerm.Term && t.Department_Id == depaId && t.Course_Id == courId ); //转ViewModel teachingTask = teachingTask.OrderBy(t => t.TeachingTaskNum); return _adapter.Adapt<TeachingTaskView>(teachingTask); }
/// <summary> /// 根据学生ID,取学生可退还教材 /// </summary> /// <param name="studentId"></param> /// <returns></returns> public IEnumerable<DropBookForStudentQueryView> GetStudentDropBookByStudentId(string studentId) { var sId = studentId.ConvertToGuid(); var currentTerm = new TermAppl().GetCurrentTerm(); var dropStudentBook = _studentReleaseRecordRepo.Find(s => s.Student_Id == sId && s.SchoolYearTerm.Year == currentTerm.SchoolYearTerm.Year && s.SchoolYearTerm.Term == currentTerm.SchoolYearTerm.Term ).Select(s => new { YearTerm = s.SchoolYearTerm, TextbookName = s.Name, TextbookId = s.Textbook_Id, ReleaseCount = s.ReleaseCount, ReleaseDate = s.ReleaseDate, ReleasePerson = s.OutStockRecord.Operator, RecipientName = s.Recipient1Name, RecipientTelephone = s.Recipient1Phone, ReleaseRecordId = s.ID }); return _typeAdapter.Adapt<DropBookForStudentQueryView>(dropStudentBook); }
/// <summary> /// 取学年学期 /// </summary> /// <returns></returns> public IEnumerable<TermView> GetTerm() { var terms = new TermAppl().GetAll(); return _adapter.Adapt<TermView>(terms); }
//public ResponseView SubmitStudentDeclaration(IEnumerable<TeachingTaskView> teachingTaskViews, string textbookId, string loginName, string mobile, string telephone, string declarationCount) public ResponseView SubmitStudentDeclaration(DeclarationView view) { //数据类型转换 var count = view.DeclarationCount.ConvertToInt(); //取对象 var term = new TermAppl().GetMaxTerm().YearTerm; //学期 var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId; //教师ID var teacher = _teacherRepo.First(t => t.ID == teacId); //教师 var repo = ServiceLocator.Current.GetInstance<IStudentDeclarationRepository>();//CUD专用仓储 //重载构造函数参数的写法,使得仓储共用工作单元,实现事务 //配置文件中要添加name为Update的IUnitOfWork的Mapto //var declRepo = ServiceLocator.Current.GetInstance<IDeclarationRepository>(new ParameterOverrides() // { // {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")} // }); //var subRepo = ServiceLocator.Current.GetInstance<ISubscriptionRepository>(new ParameterOverrides() // { // {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")} // }); //操作响应类 var result = new ResponseView(); //错误消息 var faultMessage = string.Empty; //返回消息 var messageForResponse = new StringBuilder(); //成功数量 var successCount = 0; //需要教材 //if (!view.NotNeedTextbook) //{ // //取教材 // var textId = view.TextbookId.ConvertToGuid(); // var book = _textbookRepo.First(t => t.ID == textId); //教材 // //为教学任务中的每个学生班级创建用书申报 // foreach (var item in view.TeachingTaskNums) // { // //取教学任务 // var task = _teachingTaskRepo.First(t => t.TeachingTaskNum == item); // //创建学生用书申报 // var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook); // //取出教学任务中的学生班级,依次处理 // foreach (var proClass in task.ProfessionalClasses) // { // //检查班级是否满足申报条件 // if (Domain.DeclarationService.CanDeclaration(proClass, book, ref faultMessage)) // { // //创建申报班级 // Domain.DeclarationService.CreateDeclarationClass(declaration, proClass); // } // else // { // //记录出错信息 // messageForResponse.Append(faultMessage); // faultMessage = string.Empty; // } // } // //检查可申报该教材的班级数量 // if (declaration.DeclarationClasses.Count() == task.ProfessionalClasses.Count()) // { // //将申报添加到仓储 // repo.Add(declaration); // successCount++; // } // } //} //else //不需要教材 //{ // foreach (var item in view.TeachingTaskNums) // { // //创建学生用书申报 // var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, null, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook); // //将申报添加到仓储 // repo.Add(declaration); // successCount++; // } //} try { //将申报保存到数据库 repo.Context.Commit(); //返回消息 result.Message = string.Format("共{0}个教学班,成功{1}个教学班", view.TeachingTaskNums.Count(), successCount ); //如果没有全部成功提交,增加错误消息 if (view.TeachingTaskNums.Count() != successCount) { result.Message += string.Format(",失败{0}个教学班{1}失败原因:{2}", view.TeachingTaskNums.Count() - successCount, " ", messageForResponse ); } return result; } catch (Exception e) { result.IsSuccess = false; result.Message = "提交学生用书申报失败"; return result; } }
//public ResponseView SubmitStudentDeclaration(IEnumerable<TeachingTaskView> teachingTaskViews, string textbookId, string loginName, string mobile, string telephone, string declarationCount) public ResponseView SubmitStudentDeclaration(DeclarationView view) { //数据类型转换 var count = view.DeclarationCount.ConvertToInt(); //取对象 var term = new TermAppl().GetMaxTerm().YearTerm; //学期 var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId; //教师ID var teacher = _teacherRepo.First(t => t.ID == teacId); //教师 var repo = ServiceLocator.Current.GetInstance <IStudentDeclarationRepository>();//CUD专用仓储 //重载构造函数参数的写法,使得仓储共用工作单元,实现事务 //配置文件中要添加name为Update的IUnitOfWork的Mapto //var declRepo = ServiceLocator.Current.GetInstance<IDeclarationRepository>(new ParameterOverrides() // { // {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")} // }); //var subRepo = ServiceLocator.Current.GetInstance<ISubscriptionRepository>(new ParameterOverrides() // { // {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")} // }); //操作响应类 var result = new ResponseView(); //错误消息 var faultMessage = string.Empty; //返回消息 var messageForResponse = new StringBuilder(); //成功数量 var successCount = 0; //需要教材 //if (!view.NotNeedTextbook) //{ // //取教材 // var textId = view.TextbookId.ConvertToGuid(); // var book = _textbookRepo.First(t => t.ID == textId); //教材 // //为教学任务中的每个学生班级创建用书申报 // foreach (var item in view.TeachingTaskNums) // { // //取教学任务 // var task = _teachingTaskRepo.First(t => t.TeachingTaskNum == item); // //创建学生用书申报 // var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook); // //取出教学任务中的学生班级,依次处理 // foreach (var proClass in task.ProfessionalClasses) // { // //检查班级是否满足申报条件 // if (Domain.DeclarationService.CanDeclaration(proClass, book, ref faultMessage)) // { // //创建申报班级 // Domain.DeclarationService.CreateDeclarationClass(declaration, proClass); // } // else // { // //记录出错信息 // messageForResponse.Append(faultMessage); // faultMessage = string.Empty; // } // } // //检查可申报该教材的班级数量 // if (declaration.DeclarationClasses.Count() == task.ProfessionalClasses.Count()) // { // //将申报添加到仓储 // repo.Add(declaration); // successCount++; // } // } //} //else //不需要教材 //{ // foreach (var item in view.TeachingTaskNums) // { // //创建学生用书申报 // var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, null, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook); // //将申报添加到仓储 // repo.Add(declaration); // successCount++; // } //} try { //将申报保存到数据库 repo.Context.Commit(); //返回消息 result.Message = string.Format("共{0}个教学班,成功{1}个教学班", view.TeachingTaskNums.Count(), successCount ); //如果没有全部成功提交,增加错误消息 if (view.TeachingTaskNums.Count() != successCount) { result.Message += string.Format(",失败{0}个教学班{1}失败原因:{2}", view.TeachingTaskNums.Count() - successCount, " ", messageForResponse ); } return(result); } catch (Exception e) { result.IsSuccess = false; result.Message = "提交学生用书申报失败"; return(result); } }
public ResponseView SubmitTeacherDeclaration(DeclarationView view) { //类型转换 var textId = view.TextbookId.ConvertToGuid(); var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId; var count = view.DeclarationCount.ConvertToInt(); //当前学期 var term = new TermAppl().GetMaxTerm().YearTerm; //操作响应类 var result = new ResponseView(); try { ////CUD仓储 //var repo = ServiceLocator.Current.GetInstance<ITeacherDeclarationRepository>(); ////创建申报 //var declaration = Domain.DeclarationService.CreateDeclaration<TeacherDeclaration>(term, view.TeachingTaskNums.First(), textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook); ////保存 //repo.Add(declaration); ////提交到数据库 //repo.Context.Commit(); return result; } catch (Exception e) { result.IsSuccess = false; result.Message = "提交教师用书申报失败"; return result; } }
/// <summary> /// 取学年学期 /// </summary> /// <returns></returns> public IEnumerable <TermView> GetTerm() { var terms = new TermAppl().GetAll(); return(_adapter.Adapt <TermView>(terms)); }
public IEnumerable<TermView> GetTerm() { var terms = new TermAppl().GetAll(); //排序 terms = terms.OrderByDescending(t => t.YearTerm); return _adapter.Adapt<TermView>(terms); }
/// <summary> /// 退还学生教材 /// </summary> /// <param name="releaseRecordeIds"></param> /// <param name="studentId"></param> /// <returns></returns> public ResponseView DropStudenBookSubmit(IEnumerable<string> releaseRecordeIds, string studentId) { //数据类型转换 Guid stID = studentId.ConvertToGuid(); var term = new TermAppl().GetCurrentTerm().ToString(); //根据学生Id,发放记录Id,取该生每本教材的退还数 var dorpBookCountForStudent = new List<StudentReleaseRecord>(); foreach (string recordId in releaseRecordeIds) { var rId = recordId.ConvertToGuid(); var studentRel = _studentReleaseRecordRepo.First(s => s.Student_Id == stID && s.ID == rId); dorpBookCountForStudent.Add(studentRel); } //根据发放记录Id,取对应的库存变更记录Id var stockRecordIds = new List<StudentReleaseRecord>(); foreach (string recordId in releaseRecordeIds) { var rId = recordId.ConvertToGuid(); var stockRecordId = _studentReleaseRecordRepo.First(s => s.ID == rId); stockRecordIds.Add(stockRecordId); } //根据库存变更记录Id,取库存Id var inventoryIds = new List<Domain.Models.InStockRecord>(); foreach (StudentReleaseRecord id in stockRecordIds) { var inventoryId = _inStockRecordRepo.First(i => i.ID == id.StockRecord_Id); inventoryIds.Add(inventoryId); } var result = new ResponseView(); var message = string.Empty; var messageForResponse = string.Empty; var releaseRecordCount = 0; releaseRecordCount += dorpBookCountForStudent.Count(); var successCount = 0; //删除库存变记录 foreach (StudentReleaseRecord stockRecordId in stockRecordIds) { if (stockRecordId.StockRecord_Id != null) { var stoockRecord = Domain.ReleaseBookService.CreateStockRecord(stockRecordId.StockRecord_Id.Value); _inStockRecordRepo.Remove(stoockRecord); _inStockRecordRepo.Context.Commit(); } } //修改库存数量 foreach (InStockRecord view in inventoryIds) { var releaseCount = dorpBookCountForStudent.First(d => d.StockRecord_Id == view.ID).ReleaseCount; var inventory = Domain.ReleaseBookService.CreatInventoryAtDrop(view.Inventory_Id, releaseCount); _inventoryRepo.Modify(inventory); _inventoryRepo.Context.Commit(); } //删除学生发放记录 foreach (StudentReleaseRecord view in dorpBookCountForStudent) { var studentRecord = Domain.ReleaseBookService.CreateStudentDropReleaseRecord( view.ID, stID); _studentReleaseRecordRepo.Remove(studentRecord); _studentReleaseRecordRepo.Context.Commit(); successCount++; } return result; }
/// <summary> /// 退还班级教材 /// </summary> /// <param name="classId"></param> /// <param name="releaseRecordIds"></param> /// <returns></returns> public ResponseView DropClassBookSubmit(string classId, IEnumerable<string> releaseRecordIds) { //数据类型转换 Guid cId = classId.ConvertToGuid(); var term = new TermAppl().GetCurrentTerm().ToString(); //根据发放记录Id,当前学期,取该班级每本教材的退还数 var dorpBookCountForClass = new List<Domain.Models.StudentReleaseRecord>(); foreach (string recordId in releaseRecordIds) { var rId = recordId.ConvertToGuid(); var classRel = _studentReleaseRecordRepo.Find(s => s.Class_Id == cId && s.ID == rId).GroupBy(s => new { s.Textbook_Id, s.ID }).Select(d => new StudentReleaseRecord() { ID = d.Key.ID, Textbook_Id = d.Key.Textbook_Id, ReleaseCount = d.Sum(s => s.ReleaseCount) }); dorpBookCountForClass.AddRange(classRel); } //根据发放记录Id,取对应的库存变更记录Id var stockRecordIds = new List<Domain.Models.StudentReleaseRecord>(); foreach (string releaseRecordId in releaseRecordIds) { var recordId = releaseRecordId.ConvertToGuid(); var stockRecordId = _studentReleaseRecordRepo.First(s => s.ID == recordId); stockRecordIds.Add(stockRecordId); } //根据库存变更记录Id,取库存Id var inventoryIds = new List<Domain.Models.InStockRecord>(); foreach (StudentReleaseRecord id in stockRecordIds) { var inventoryId = _inStockRecordRepo.First(i => i.ID == id.StockRecord_Id); inventoryIds.Add(inventoryId); } var result = new ResponseView(); var message = string.Empty; var messageForResponse = string.Empty; var releaseRecordCount = 0; releaseRecordCount += releaseRecordIds.Count(); var successCount = 0; //删除库存变记录 foreach (Domain.Models.StudentReleaseRecord stockRecordId in stockRecordIds) { if (stockRecordId.StockRecord_Id != null) { var stoockRecord = Domain.ReleaseBookService.CreateStockRecord(stockRecordId.StockRecord_Id.Value); _inStockRecordRepo.Remove(stoockRecord); _inStockRecordRepo.Context.Commit(); } } //修改库存数量 foreach (InStockRecord view in inventoryIds) { var releaseCount = dorpBookCountForClass.First(d => d.StockRecord_Id == view.ID).ReleaseCount; var inventory = Domain.ReleaseBookService.CreatInventoryAtDrop(view.Inventory_Id, releaseCount); _inventoryRepo.Modify(inventory); _inventoryRepo.Context.Commit(); } //删除班级发放记录 foreach (string releaseRecordId in releaseRecordIds) { var claID = classId.ConvertToGuid(); var studentRecord = Domain.ReleaseBookService.CreateClassDropReleaseRecord( releaseRecordId.ConvertToGuid(), claID); _studentReleaseRecordRepo.Remove(studentRecord); _studentReleaseRecordRepo.Context.Commit(); successCount++; } return result; }