public ResponseView SubmitReleaseClass(IEnumerable<InventoryForReleaseClassView> inventoryViews, ReleaseBookForClassView releaseView) { return _impl.SubmitReleaseClass(inventoryViews, releaseView); }
public ResponseView SubmitReleaseClass(IEnumerable<InventoryForReleaseClassView> inventoryViews, ReleaseBookForClassView releaseView) { return new ResponseView(); //var user = new TbmisUserAppl(releaseView.Operator).GetUser(); //var person = user.TbmisUserName; //var term = new TermAppl().GetMaxTerm().YearTerm; //var result = new ResponseView(); //var repo = ServiceLocator.Current.GetInstance<IInventoryRepository>(); ////修改库存记录 //foreach (var item in inventoryViews) //{ // //取库存 // var inventoryId = item.InventoryId.ConvertToInt(); // var inventory = repo.First(t => t.InventoryId == inventoryId); // //取领书的学生 // var students = item.Students.Where(t => t.CheckFlag == true); // //创建出库记录 // var stockRecord = InventoryService.CreateStockRecord<OutStockRecord>(inventory, person, 0); // //创建学生发放记录 // //只处理选中的学生 // foreach (var record in students) // { // var studentId = record.StudentId.ConvertToGuid(); // var student = new StudentAppl().GetById(studentId); // var studentRecord = new StudentReleaseRecord // { // ReleaseRecordId = Guid.NewGuid(), // Author = item.Author, // Bookseller_Id = (Guid)user.SchoolId, // BooksellerName = user.SchoolName, // Class_Id = student.ProfessionalClass_Id, // ClassName = student.ProfessionalClass.Name, // Edition = item.Edition.ConvertToInt(), // Gender = record.Gender, // Isbn = item.Isbn, // IsSelfCompile = item.IsSelfCompile.ConvertToBool(), // Num = item.Num.ConvertToInt(), // Name = item.Name, // PageCount = item.PageCount.ConvertToInt(), // Press = item.Press, // PressAddress = item.PressAddress, // Price = item.Price, // Discount = item.Discount, // DiscountPrice = item.DiscountPrice, // PrintCount = item.PrintCount.ConvertToInt(), // PublishDate = item.PublishDate, // Recipient1Name = releaseView.RecipientName, // Recipient1Phone = releaseView.RecipientTelephone, // Recipient2Name = releaseView.Recipient2Name, // Recipient2Phone = releaseView.Recipient2Telephone, // //ReleaseCount = (int)Math.Floor(releaseCount / students.Count()),//人均发放数量 = 应发总数 / 未领书人数,取地板 // ReleaseCount = item.AverageCount, // ReleaseDate = DateTime.Now, // School_Id = student.ProfessionalClass.School_Id, // SchoolName = student.ProfessionalClass.School.Name, // Student_Id = student.StudentId, // StudentNum = student.Num, // StudentName = student.Name, // Textbook_Id = item.TextbookId.ConvertToGuid(), // TextbookType = item.TextbookType, // StockRecord_Id = stockRecord.StockRecordId, // Term = term // }; // //检查发放数量,避免为0,最少是1 // if (studentRecord.ReleaseCount == 0) // { // studentRecord.ReleaseCount = 1; // } // //添加发放记录 // stockRecord.ReleaseRecords.Add(studentRecord); // //修改出入库数量 // stockRecord.StockCount += studentRecord.ReleaseCount; // } // //修改库存 // inventory.InventoryCount -= stockRecord.StockCount; // //检查库存数量 // if (inventory.InventoryCount <= 0) // { // result.IsSuccess = false; // result.Message = "库存数量不足,无法继续发放"; // return result; // } // //添加到仓储 // repo.Modify(inventory); //} //try //{ // repo.Context.Commit(); // return result; //} //catch (Exception e) //{ // result.IsSuccess = false; // result.Message = "发放失败"; // return result; //} }