Example #1
0
        public IActionResult searchBook(string titleBook)
        {
            DashboardModel dashboard       = new DashboardModel(HttpContextAccessor);
            string         userNameSession = dashboard.getUserSession();
            int            userId          = dashboard.User.validUserId(userNameSession);
            //Verify which books have in own database
            //Get List from books
            List <DashboardModel> listBooksOwn     = dashboard.Book.getListBook(titleBook, userId);
            List <DashboardModel> listBooksService = new List <DashboardModel>();

            try
            {
                //Get List from service
                listBooksService = dashboard.GoogleAPIBook.getListBook(titleBook);
            }
            catch { }


            //Merge these list and delete the duplicates itens
            listBooksService.RemoveAll(serv => listBooksOwn.Exists(own => own.Book.GoogleId == serv.Book.GoogleId && own.Book.IdBook != serv.Book.IdBook));
            //Add the database List
            //listBooksService.AddRange(listBooksOwn);
            listBooksService.InsertRange(0, listBooksOwn);

            TempData["textSearched"] = titleBook;
            TempData["userId"]       = userId;

            ViewBag.ListBook = listBooksService;
            return(View("Index"));
        }
Example #2
0
        public IActionResult Index()
        {
            DashboardModel dashboard   = new DashboardModel(HttpContextAccessor);
            string         userSession = dashboard.getUserSession();
            bool           flag        = dashboard.validUserSession();

            if (flag)
            {
                int  idUser     = dashboard.User.validUserId(userSession);
                char firstAcess = dashboard.User.getFirstAccess(userSession);
                if (firstAcess == '1')
                {
                    return(RedirectToAction("FirstAccess", "Dashboard"));
                }
                else
                {
                    //bring dats to status
                    string[] status = dashboard.UserBook.getStatusUser(idUser);
                    TempData["qntBook"]        = status[0];
                    TempData["qntBookRead"]    = status[1];
                    TempData["qntBookReading"] = status[2];
                    TempData["userId"]         = idUser;
                    TempData["totalRegister"]  = dashboard.UserBook.TotalRegister(idUser, "");
                    TempData["currentPage"]    = 1;
                    TempData["quantityPage"]   = 5;
                    ViewBag.ListBook           = dashboard.UserBook.getListUserBook(idUser, 5, 1, "");
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public IActionResult EditUserBook(int IdUserBook)
        {
            DashboardModel dashboard       = new DashboardModel(HttpContextAccessor);
            string         userNameSession = dashboard.getUserSession();
            int            userId          = dashboard.User.validUserId(userNameSession);

            dashboard = dashboard.UserBook.getUserBook(IdUserBook, userId);
            TempData["typeAction"] = "edit";
            return(View("Manage"));
        }
Example #4
0
        public IActionResult UpdateFirstAccess(string typeData, string validDate, string question, string answer)
        {
            DashboardModel dashboard   = new DashboardModel(HttpContextAccessor);
            string         userSession = dashboard.getUserSession();
            UserModel      localUser   = new UserModel();
            bool           flag        = dashboard.User.updateForgetPassword(userSession, typeData, validDate, question, answer);

            if (flag)
            {
                flag = localUser.updateFirstAccess(userSession);
                if (flag)
                {
                    return(RedirectToAction("Index", "Dashboard"));
                }
            }
            return(RedirectToAction("FirstAccess", "Dashboard"));
        }
Example #5
0
        public IActionResult FirstAccess()
        {
            DashboardModel dashboard   = new DashboardModel(HttpContextAccessor);
            string         userSession = dashboard.getUserSession();
            bool           flag        = dashboard.validUserSession();

            if (flag)
            {
                char firstAcess = dashboard.User.getFirstAccess(userSession);
                if (firstAcess == '0')
                {
                    return(RedirectToAction("Index", "Dashboard"));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }