public void Adduser(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.UserNameLabel); string userName = Console.ReadLine(); Console.Write(StringLiterals.EmailLabel); string email = Console.ReadLine(); Console.Write(StringLiterals.PasswordLabel); string pass = Console.ReadLine(); Console.Write(StringLiterals.TypeOfUserLabel); bool IsAdmin = Console.ReadLine().Equals(StringLiterals.One) ? true : false; if (userName == StringLiterals.nullLabel && email == StringLiterals.nullLabel && pass == StringLiterals.nullLabel) { Console.WriteLine(StringLiterals.ValidationsErrorMsg); } else { Console.WriteLine(bookOp.AddUser(new UserModel() { Name = userName, Email = email, IsActive = true, Password = pass, IsAdmin = IsAdmin })); } }
static void Main(string[] args) { for (; true;) { Console.SetCursorPosition((Console.WindowWidth - StringLiterals.WelcomeMsg.Length) / 2, Console.CursorTop); Console.WriteLine(StringLiterals.WelcomeMsg); Console.Write(StringLiterals.UserNameLabel); string username = Console.ReadLine(); Console.Write(StringLiterals.PasswordLabel); string password = Console.ReadLine(); IAuthentication obj = BALFactory.GetAuthenticationObject(); if (obj.Authenticate(new AuthModel() { Email = username, Password = password })) { Console.WriteLine(StringLiterals.LoginSuccessMsg); IBookModule bookOp = BALFactory.GetBookModuleObject(); OperationsUI driveUI = new OperationsUI(); driveUI.StartPoint(bookOp, username); } else { Console.WriteLine(StringLiterals.InvalidCredentialsMsg); } Thread.Sleep(1000); Console.Clear(); } }
public void RemoveUser(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.EnterUserIDPrompt); int removeID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(bookOp.RemoveUser(removeID)); }
public void RemoveBook(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.EnterBookIDPrompt); int id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(bookOp.RemoveBook(id)); }
public void ReturnBook(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.EnterBookIDPrompt); int studID = Convert.ToInt32(Console.ReadLine()); Console.Write(StringLiterals.EnterRemarksPrompt); string remarks = Console.ReadLine(); Console.WriteLine(StringLiterals.NewLine + bookOp.ReturnBook(studID, remarks) + StringLiterals.NewLine); Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); }
public void GetStudentLog(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.UserIdLabel); int studId = Convert.ToInt32(Console.ReadLine()); foreach (DataRow i in bookOp.GetStudentLog(studId).Rows) { Console.WriteLine(StringLiterals.NewLine + i["BookID"].ToString() + StringLiterals.NewLine + i["Name"].ToString() + StringLiterals.NewLine); } Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); }
public static int UserChoiceSelect() { IBookModule BookChoice = BALFactory.GetBookModuleObject(); int choice; Console.WriteLine(StringLiterals.UserChoice); Console.Write(StringLiterals.ChoiceEntry); choice = Int32.Parse(Console.ReadLine()); switch (choice) { case 1: Console.Clear(); Console.WriteLine(StringLiterals.BookName); string _searcharg = Console.ReadLine(); DataTable _srchList = BookChoice.SearchBook(_searcharg); foreach (DataRow item in _srchList.Rows) { Console.WriteLine(StringLiterals.SearchResult, item[0], item[1], item[3], item[2]); } Console.WriteLine(StringLiterals.PressContinue); Console.ReadKey(); Console.Clear(); break; case 2: Console.Clear(); Console.WriteLine(StringLiterals.UserID); int _userID = Int32.Parse(Console.ReadLine()); DataTable histList = BookChoice.HistoryOfUser(_userID); foreach (DataRow item in histList.Rows) { Console.WriteLine(StringLiterals.UserHistory, item[0], item[2], item[3], item[7]); } break; case 3: Console.Clear(); Console.WriteLine(StringLiterals.EnterBookDetails); Console.Write(StringLiterals.BookID); int _bookID = Int32.Parse(Console.ReadLine()); Console.WriteLine(BookChoice.CheckBookAvailability(_bookID)); break; case 4: Console.WriteLine(StringLiterals.SignOut); return(1); } return(0); }
public void GetLog(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.ChooseLogOptionPrompt); LogChoice logOption = (LogChoice)Enum.Parse(typeof(LogChoice), Console.ReadLine()); switch (logOption) { case LogChoice.AllLog: Console.Clear(); Console.WriteLine(StringLiterals.DisplayLogTillNowMsg); foreach (DataRow row in bookOp.GetLog().Rows) { if (row["ReturnedAt"].ToString() == default(DateTime).ToString()) { Console.WriteLine("BookID: {0}\nTaken by: {1}\nIssued by: {2}\nIssued at: {3}\nReturned at: Need to be returned\nRemarks: {4}\n", row["BookID"].ToString(), row["UserID"].ToString(), row["PerformedByID"].ToString(), row["OperationPerformedAt"].ToString(), row["Remarks"].ToString()); } else { Console.WriteLine("BookID: {0}\nTaken by: {1}\nIssued by: {2}\nIssued at: {3}\nReturned at: {4}\nRemarks: {5}\n", row["BookID"].ToString(), row["UserID"].ToString(), row["PerformedByID"].ToString(), row["OperationPerformedAt"].ToString(), row["ReturnedAt"].ToString(), row["Remarks"].ToString()); } } break; case LogChoice.DateLog: Console.Clear(); Console.Write(StringLiterals.EnterDatePrompt); DateTime dtlog = DateTime.Parse(Console.ReadLine()); Console.WriteLine(StringLiterals.DisplayingLogTillDate + dtlog); Console.WriteLine(StringLiterals.IssuesMsg); foreach (DataRow row in bookOp.GetIssueLogByDate(dtlog).Rows) { Console.WriteLine("BookID: {0}\nTaken by: {1}\nIssued by: {2}\nIssued at: {3}\nRemarks: {4}\n", row["BookID"].ToString(), row["UserID"].ToString(), row["PerformedByID"].ToString(), row["OperationPerformedAt"].ToString(), row["Remarks"].ToString()); } Console.WriteLine(StringLiterals.ReturnsMsg); foreach (DataRow row in bookOp.GetReturnLogByDate(dtlog).Rows) { Console.WriteLine("BookID: {0}\nTaken by: {1}\nIssued by: {2}\nReturned at: {3}\nRemarks: {4}\n", row["BookID"].ToString(), row["UserID"].ToString(), row["PerformedByID"].ToString(), row["OperationPerformedAt"].ToString(), row["Remarks"].ToString()); } break; default: Console.WriteLine(StringLiterals.Error); break; } Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); }
public void ShowBooks(IBookModule bookOp) { Console.Clear(); Console.WriteLine(StringLiterals.SelectMsg); Console.WriteLine(StringLiterals.SelectBooksMsg); string choice = Console.ReadLine(); Choice choices = (Choice)Enum.Parse(typeof(Choice), choice); switch (choices) { case Choice.All: Console.WriteLine(StringLiterals.DisplayingAllBooksMsg); foreach (DataRow row in bookOp.GetBooks(choice).Rows) { Console.WriteLine("\nBook Id: {0}\nBook Name: {1}\nDepartment: {2}\nAuthor: {3}\nIs available: {4}\nIs Enabled: {5}\n", row["BookID"].ToString(), row["Name"].ToString(), row["Department"].ToString(), row["AuthorName"].ToString(), row["IsAvailable"].ToString(), row["IsActive"].ToString()); } Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); break; case Choice.Active: Console.WriteLine(StringLiterals.DisplayingEnabledBooksMsg); foreach (DataRow row in bookOp.GetBooks(choice).Rows) { Console.WriteLine("\nBook Id: {0}\nBook Name: {1}\nDepartment: {2}\nAuthor: {3}\nIs available: {4}\n", row["BookID"].ToString(), row["Name"].ToString(), row["Department"].ToString(), row["AuthorName"].ToString(), row["IsAvailable"].ToString()); } Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); break; case Choice.Available: Console.WriteLine(StringLiterals.DisplayingAvailableBooksMsg); foreach (DataRow row in bookOp.GetBooks(choice).Rows) { Console.WriteLine("\nBook Id: {0}\nBook Name: {1}\nDepartment: {2}\nAuthor: {3}\n", row["BookID"].ToString(), row["Name"].ToString(), row["Department"].ToString(), row["AuthorName"].ToString()); } Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); break; default: Console.WriteLine(StringLiterals.NewLine + StringLiterals.ValidationsErrorMsg); Thread.Sleep(2000); break; } }
public void IssueBook(IBookModule bookOp, string username) { Console.Clear(); Console.Write(StringLiterals.EnterBookIDPrompt); int bookid = Convert.ToInt32(Console.ReadLine()); Console.Write(StringLiterals.EnterStudIDPrompt); int studid = Convert.ToInt32(Console.ReadLine()); Console.Write(StringLiterals.EnterRemarksPrompt); string remark = Console.ReadLine(); Console.WriteLine(StringLiterals.NewLine + bookOp.IssueBook(new BookHistoryModel() { BookID = bookid, UserID = studid, OperationPerofrmedAt = DateTime.Today, PerformedByID = username, Remarks = remark }) + StringLiterals.NewLine); Console.WriteLine(StringLiterals.PressAnyKeyPrompt); Console.ReadKey(); }
public void AddBook(IBookModule bookOp) { Console.Clear(); Console.Write(StringLiterals.BookNameLabel); string name = Console.ReadLine(); Console.Write(StringLiterals.DeptNameLabel); string dept = Console.ReadLine(); Console.Write(StringLiterals.AuthorNameLabel); string author = Console.ReadLine(); if (name == StringLiterals.nullLabel && dept == StringLiterals.nullLabel && author == StringLiterals.nullLabel) { Console.WriteLine(StringLiterals.ValidationsErrorMsg); } else { Console.WriteLine(bookOp.AddBook(new BookModel() { Name = name, Department = dept, AuthorName = author, IsAvailable = true, IsActive = true })); } }
/// <summary> /// Exectution starts from here /// </summary> /// <param name="args"></param> static void Main(string[] args) { IAuthentication obj = BALFactory.GetAuthenticationObject(); Console.BackgroundColor = ConsoleColor.Black; Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; AuthenticationPage: Console.WriteLine("Enter Admin Mail id"); string adminid = Console.ReadLine(); Console.WriteLine("Enter Admin Password"); string pwd = Console.ReadLine(); bool result = obj.Authenticate(new AuthModel { Email = adminid, Password = pwd }); if (result) { IUserModule uobj = BALFactory.GetUserModuleObject(); IBookModule bobj = BALFactory.GetBookModuleObject(); Console.WriteLine("\nLogin Sucessfull"); bool logout = false; do { Console.WriteLine("\n--------MENU--------"); Console.WriteLine("\n1) To Logout\n" + "\n2)Add Book\n" + "\n3)Get All Books\n" + "\n4)Lists NotActive Books\n" + "\n5)Make a Book Disable\n" + "\n6)Enable Book\n" + "\n7)Issue a Book\n" + "\n8)Return Book\n" + "\n9)Lists Available Books in BookHistoryDateBase\n" + "\n10)Add users\n" + "\n11)To Exit from the Application\n" + "\n12)Lists The all Users Details\n" + "\n13)Check Availabliity of Books"); Console.WriteLine("\nEnter your choice"); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: { Console.WriteLine("Logout Sucessfully"); logout = true; //To Login Again goto AuthenticationPage; } case 2: { Console.WriteLine("\nEnter Book Name"); string bookname = Console.ReadLine(); Console.WriteLine("\nEnter Author Name"); string authorname = Console.ReadLine(); Console.WriteLine("\nEntet Department"); string dept = Console.ReadLine(); int lastBookId = bobj.LastBookId(); lastBookId += 1; Console.WriteLine("\nEntet Number of copies to add"); int bookcount = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < bookcount; i++, lastBookId++) { bobj.AddBook(new BookModel { BookID = lastBookId, Name = bookname, AuthorName = authorname, Department = dept, IsActive = true }); } Console.WriteLine(+bookcount + "Added Sucessfully"); break; } case 3: { IEnumerable <BookModel> GetAllBooks = bobj.GetAllBooks(true); Console.WriteLine("\n------Entire Books in Library are -------\n"); foreach (BookModel item in GetAllBooks) { Console.WriteLine("\nBookId \t:{0}\nBook Name\t:{1}\nAuthor Name\t:{2}\nDepartment\t:{3}", item.BookID, item.Name, item.AuthorName, item.Department); } break; } case 4: { IEnumerable <BookModel> listsbooks = bobj.ListDisableBooks(false); Console.WriteLine("\n------NotActive Books in Library are -------\n"); foreach (BookModel item in listsbooks) { Console.WriteLine("\nBookId \t:{0}\nBook Name\t:{1}\nAuthor Name\t:{2}\nDepartment\t:{3}", item.BookID, item.Name, item.AuthorName, item.Department); } break; } case 5: { Console.WriteLine("Enter BookId to diable"); int bookId = Convert.ToInt32(Console.ReadLine()); bobj.DisableBook(bookId); break; } case 6: { Console.WriteLine("Enter BookId to Enable"); int bookid = Convert.ToInt32(Console.ReadLine()); bobj.EnableBook(bookid); break; } case 7: { Console.WriteLine("Enter BookId to Issue"); int bookid = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter userId"); int userid = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter AdminId at present who is issuing the books to the users"); int adminId = Convert.ToInt32(Console.ReadLine()); DateTime?returnat = null; Console.WriteLine("\nEnter Any remarks"); string remarks = Console.ReadLine(); bobj.IssueBook(new BookHistoryModel { BookID = bookid, UserID = userid, OperationPerofrmedAt = DateTime.Now, ReturnedAt = returnat, PerformedByID = adminId, Remarks = remarks, IsAvilable = false }); break; } case 8: { Console.WriteLine("Enter Userid who is returning the book"); int userId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter bookId"); int bookId = Convert.ToInt32(Console.ReadLine()); //DateTime? returnat = null; Console.WriteLine("\nDid you found remarks"); string remarks = Console.ReadLine(); bobj.ReturnBook(userId, bookId); break; } case 9: { IEnumerable <BookHistoryModel> history = bobj.EntireHistory(); foreach (BookHistoryModel item in history) { Console.WriteLine("\nBookID \t:{0}\nUserId \t:{1}\nAdmin ID{2}\nBook Returned\t:{3}\nAvailability\t:{4}\nAny Remarks\t:{5}" , item.BookID, item.UserID, item.PerformedByID, item.ReturnedAt, item.IsAvilable, item.Remarks); } break; } case 10: { Console.WriteLine("Enter New userid"); //UserID=1, Name="User1", Email="Author1", IsActive=true, Password="******", IsAdmin=true int userId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter name for user"); string name = Console.ReadLine(); Console.WriteLine("Enter New Email Id"); string email = Console.ReadLine(); Console.WriteLine("Enter some password to new user"); string password = Console.ReadLine(); Console.WriteLine("Did you want to make user as admin or not"); string admin = Console.ReadLine(); uobj.AddUser(new UserModel { UserID = userId, Name = name, Email = email, IsActive = true, Password = "******", IsAdmin = true }); break; } case 11: { //this.close(); Environment.Exit(0); break; } //UserID=1, Name="User1", Email="Author1", IsActive=true, Password="******", IsAdmin=true case 12: { Console.WriteLine("Entire User Details are"); IEnumerable <UserModel> userlist = uobj.GetAllUserDetails(true || false); foreach (UserModel item in userlist) { Console.WriteLine("\nUserID\t:{0}\nName\t:{1}\nEmail\t:{2}\nIsActive\t:{3}\nPassword\t:{4}\nIsAdmin" + item.UserID, item.Name, item.Email, item.IsActive, item.Password, item.IsAdmin); } break; } case 13: { Console.WriteLine("Enter Book name to check"); string bookname = Console.ReadLine(); var count = bobj.CheckBookAvailability(bookname); if (count > 0) { Console.WriteLine(" \n{0} Books are Available", count); } else { Console.WriteLine("No Book Found"); } break; } } }while (!logout); Console.WriteLine("You are Logged out Sucessfully"); } }
public void StartPoint(IBookModule bookOp, string username) { for (; true;) { Console.Clear(); Console.WriteLine(StringLiterals.SelectMsg); Console.WriteLine(StringLiterals.OptionsMsg); Option opt = (Option)Enum.Parse(typeof(Option), Console.ReadLine()); if (opt == Option.Logout) { break; } switch (opt) { case Option.AddBook: AddBook(bookOp); Thread.Sleep(2000); break; case Option.ShowBooks: ShowBooks(bookOp); break; case Option.Issue: IssueBook(bookOp, username); break; case Option.Return: ReturnBook(bookOp); break; case Option.RemoveBook: RemoveBook(bookOp); Thread.Sleep(2000); break; case Option.Log: GetLog(bookOp); break; case Option.StudentsBooks: GetStudentLog(bookOp); break; case Option.AddUser: Adduser(bookOp); Thread.Sleep(2000); break; case Option.RemoveUser: RemoveUser(bookOp); Thread.Sleep(2000); break; default: Console.WriteLine(StringLiterals.Error); Thread.Sleep(1000); break; } Console.Clear(); } }
public static int AdminChoiceSelect() { IBookModule BookChoice = BALFactory.GetBookModuleObject(); int choice; Console.WriteLine(StringLiterals.Welcome); Console.WriteLine(StringLiterals.AdminChoice); Console.Write(StringLiterals.ChoiceEntry); choice = Int32.Parse(Console.ReadLine()); switch (choice) { case 1: Console.Clear(); Console.WriteLine(StringLiterals.EnterBookDetails); Console.Write(StringLiterals.BookName); string _bookName = Console.ReadLine(); Console.Write(StringLiterals.BookAuthor); string _bookAuthor = Console.ReadLine(); Console.Write(StringLiterals.BookDepartment); string _bookDept = Console.ReadLine(); Console.Write(StringLiterals.Remarks); string _bookRemarks = Console.ReadLine(); Console.Write(StringLiterals.NumberofBooks); int _bookCount = Int32.Parse(Console.ReadLine()); for (int _loopAdd = 0; _loopAdd < _bookCount; _loopAdd++) { BookChoice.AddBook(new BookModel { Name = _bookName, AuthorName = _bookAuthor, Department = _bookDept, Remarks = _bookRemarks, IsActive = true }); } break; case 2: Console.Clear(); BookHistoryModel issueInfo = new BookHistoryModel(); Console.WriteLine(StringLiterals.IssuingDetails); Console.Write(StringLiterals.BookID); issueInfo.BookID = Int32.Parse(Console.ReadLine()); Console.Write(StringLiterals.UserID); issueInfo.UserID = Int32.Parse(Console.ReadLine()); Console.Write(StringLiterals.IssueTime); issueInfo.OperationPerformedAt = DateTime.Now; Console.WriteLine(issueInfo.OperationPerformedAt); Console.Write(StringLiterals.Validity); issueInfo.ReturnedAt = DateTime.Now.AddDays(30); Console.WriteLine(issueInfo.ReturnedAt); Console.Write(StringLiterals.Remarks); issueInfo.Remarks = Console.ReadLine(); Console.Write(StringLiterals.AuthorityID); issueInfo.PerformedByID = Int32.Parse(Console.ReadLine()); string _issuemsg = BookChoice.IssueBook(issueInfo); Console.WriteLine(_issuemsg); break; case 3: Console.Clear(); Console.WriteLine(StringLiterals.EnterBookDetails); Console.Write(StringLiterals.BookID); int _returnID = Int32.Parse(Console.ReadLine()); string _retMsg = BookChoice.ReturnBook(_returnID); Console.WriteLine(_retMsg); break; case 4: Console.Clear(); Console.WriteLine(StringLiterals.BookID); int _removeID = Int32.Parse(Console.ReadLine()); string _removemsg = BookChoice.RemoveBook(_removeID); Console.WriteLine(_removemsg); break; case 5: Console.Clear(); int _getList = 0; Console.WriteLine(StringLiterals.BookListChoice); int _listChoice = Int32.Parse(Console.ReadLine()); Console.Clear(); if (_listChoice == 1) { _getList = 1; } else if (_listChoice == 2) { _getList = 2; } else if (_listChoice == 3) { _getList = 3; } else { Console.WriteLine(StringLiterals.InvalidEntry); } DataTable BookList = BookChoice.GetAllBooks(_getList); foreach (DataRow item in BookList.Rows) { Console.WriteLine(StringLiterals.BookListOut, item[0], item[1], item[3], item[2]); } Console.Write(StringLiterals.PressContinue); Console.ReadKey(); Console.Clear(); break; case 6: historylabel : Console.Clear(); Console.WriteLine(StringLiterals.BookHistoryChoice); _listChoice = Int32.Parse(Console.ReadLine()); DataTable histList = BookChoice.HistoryOfBook(_listChoice); if (_listChoice == 1) { foreach (DataRow item in histList.Rows) { Console.WriteLine(StringLiterals.IssueOut, item[0], item[1], item[2], item[7]); } } else if (_listChoice == 2) { foreach (DataRow item in histList.Rows) { Console.WriteLine(StringLiterals.ReturnOut, item[0], item[1], item[3], item[7]); } } else if (_listChoice == 3) { foreach (DataRow item in histList.Rows) { Console.WriteLine(StringLiterals.AllLog, item[0], item[1], item[2], item[3], item[7]); } } else { Console.Write(StringLiterals.InvalidEntry); goto historylabel; } Console.ReadKey(); Console.Clear(); break; case 7: Console.Clear(); Console.WriteLine(StringLiterals.BookName); string _searcharg = Console.ReadLine(); DataTable _srchList = BookChoice.SearchBook(_searcharg); foreach (DataRow item in _srchList.Rows) { Console.WriteLine(StringLiterals.SearchResult, item[0], item[1], item[3], item[2]); } Console.WriteLine(StringLiterals.PressContinue); Console.ReadKey(); Console.Clear(); break; case 8: Console.Clear(); IAuthentication _userEntry = BALFactory.GetAuthenticationObject(); UserModel _newuser = new UserModel(); Console.WriteLine(StringLiterals.UserEntry); Console.Write(StringLiterals.UserName); _newuser.Name = Console.ReadLine(); Console.Write(StringLiterals.UserEmail); _newuser.Email = Console.ReadLine(); Console.WriteLine(_userEntry.Register(_newuser)); break; case 9: Console.WriteLine(StringLiterals.SignOut); return(1); } return(0); }