public ActionResult book_return(int id, string userid, string username, string sl, string bname, string bdate, string rdate, string ratdate, string fine) { if (!String.IsNullOrEmpty(userid) && !String.IsNullOrEmpty(username)) { var b = service.GetAll().Where(d => d.serialno == sl && d.book_name == bname).FirstOrDefault(); Ibookreturnservice brservice = servicefactory.getbookreturnservice(); bookreturn br = new bookreturn(); br.userid = Convert.ToInt32(userid); br.username = username; br.serialno = sl; br.book_name = bname; br.borrow_date = bdate; br.return_date = rdate; br.return_at = ratdate; br.fine = Convert.ToInt32(fine); brservice.insert(br); b.amount = b.amount + 1; service.update(b); bservice.delete(id); ViewBag.msg = "Return successfully done...!!!"; return(View(br)); } else { bookreturn br = new bookreturn(); ViewBag.msg = "Something wrong...!!!"; return(View(br)); } }
// GET: report public ActionResult Index() { Ibookreturnservice service = servicefactory.getbookreturnservice(); var users = service.GetAll().Where(d => Convert.ToDateTime(d.return_at) >= Convert.ToDateTime(d.return_date)).OrderBy(d => d.return_at).Take(3); //GroupBy(d => d.userid).Max() // IEnumerable< bookreturn> users = service.GetAll().Where(a => a.userid).Count; List <bookreturnmodel> viewlist = new List <bookreturnmodel>(); foreach (bookreturn u in users) { bookreturnmodel user = new bookreturnmodel() { userid = u.userid, username = u.username, serialno = u.serialno, book_name = u.book_name, borrow_date = u.borrow_date, return_date = u.return_date, return_at = u.return_at, fine = u.fine }; viewlist.Add(user); } return(View(viewlist)); }