コード例 #1
0
 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();
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.Title = StringLiterals.ConsoleTitle;
            IAuthentication obj    = BALFactory.GetAuthenticationObject();
            AuthModel       argObj = new AuthModel();

            Login :      Console.WriteLine(StringLiterals.EnterCredentials);
            Console.Write(StringLiterals.EmailEntry);
            argObj.Email = Console.ReadLine();
            Console.Write(StringLiterals.PasswordEntry);
            argObj.Password = Console.ReadLine();
            result          = obj.Authenticate(argObj);
            if (result == 1)
            {
                Console.Clear();
                int iterer;
                do
                {
                    iterer = AdminChoiceSelect();
                } while (iterer != 1);
            }
            else if (result == 2)
            {
                Console.Clear();
                int iterer;
                do
                {
                    iterer = UserChoiceSelect();
                } while (iterer != 1);
            }
            else if (result == 0)
            {
                Console.Clear();
                Console.WriteLine(StringLiterals.InvalidCredentials);
                goto Login;
            }
            Console.WriteLine(StringLiterals.ExitApp);
            Console.ReadKey();
        }
コード例 #3
0
        /// <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");
            }
        }
コード例 #4
0
        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);
        }