public Member_Detail findMemberById(int id) { Member_Detail memberDetail = null; try { using (var db = new ModelDB()) { memberDetail = db.Member_Detail.Find(id); } } catch (Exception ex) { Console.WriteLine(ex.InnerException); } return(memberDetail); }
public Boolean updateMember(Member_Detail member) { Boolean status = false; try { using (var db = new ModelDB()) { db.Member_Detail.AddOrUpdate(member); db.SaveChanges(); status = true; } } catch (Exception ex) { Console.WriteLine(ex.InnerException); } return(status); }
public Boolean issueBook(Book_Detail book, Member_Detail member, DateTime issueDate, DateTime retrunDate) { Issue_Detail issueDetail = new Issue_Detail(); issueDetail.book_id = book.book_id; issueDetail.member_id = member.member_id; int copies = (int)book.no_of_copies; Console.WriteLine("Number of copies now" + copies); copies--; book.no_of_copies = copies; issueDetail.issue_date = issueDate; issueDetail.due_date = retrunDate; Console.WriteLine("issue book contoller called issue book" + issueDetail); Boolean status = false; try { using (var db = new ModelDB()) { db.Issue_Detail.Add(issueDetail); db.SaveChanges(); status = true; BookController bookController = new BookController(); bookController.updateBook(book); } } catch (Exception ex) { Console.WriteLine("issue error " + ex.InnerException); } return(status); }