public ActionResult ReturnBooks(int[] borrowsIds, int userId) { BorrowService borrowService = new BorrowService(); borrowService.ReturnBooks(borrowsIds); var redirectUrl = new UrlHelper(Request.RequestContext).Action("UserBooks", "Borrows", userId); return(Json(new { Url = string.Concat(redirectUrl, "?userId=", userId) })); }
/// <summary> /// 执行还书操作,更新借书记录、还书记录、图书可借库存 /// </summary> /// <param name="returnList">还书记录</param> /// <param name="borrowList">借书记录</param> /// <param name="adminName">管理员姓名</param> /// <returns></returns> public bool ReturnBooks(List <BorrowDetail> returnList, List <BorrowDetail> borrowList, string adminName) { List <ReturnBook> returnBookList = new List <ReturnBook>(); foreach (BorrowDetail returnItem in returnList) { int returnCount = returnItem.ReturnCount; List <BorrowDetail> curBorrowDetails = (from b in borrowList where b.BarCode == returnItem.BarCode select b).ToList <BorrowDetail>(); curBorrowDetails.Sort(new BorrowOrderByExpireASC());//排序,到期时间早的先还 foreach (BorrowDetail borrowItem in curBorrowDetails) { if (borrowItem.NonReturnCount >= returnCount) { returnBookList.Add(new ReturnBook() { BorrowDetailId = borrowItem.BorrowDetailId, ReturnCount = returnCount, AdminName_R = adminName, BookId = borrowItem.BookId }); break; } else { returnBookList.Add(new ReturnBook() { BorrowDetailId = borrowItem.BorrowDetailId, ReturnCount = borrowItem.NonReturnCount, AdminName_R = adminName, BookId = borrowItem.BookId }); returnCount -= borrowItem.NonReturnCount; } } } return(objBorrowService.ReturnBooks(returnBookList)); }
public ActionResult ReturnBorrows(BorrowListViewModel model) { borrowService.ReturnBooks(model.BorrowsId); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }