Ejemplo n.º 1
0
        public bool Authenticated(string token)
        {
            //try
            //{
            var user = _jwtManager.DecodeTokenName(token);

            return(_userPresenter.FindUser(user) != null);
            //}
            //catch (Exception)
            //{
            //    return false;
            //}
        }
        private void TakeBookButton_Click(object sender, EventArgs e)
        {
            if (_result != null)
            {
                try
                {
                    _mTakenBookPresenter.AddTakenBook(view: _book, username: StaticDataSource.CurrUser);

                    var takenBooks = _mTakenBookPresenter.GetTakenBooks();
                    var addedBook  = takenBooks.First(item => item.Code == _book.Code && item.TakenByUser ==
                                                      StaticDataSource.CurrUser);

                    var bookReturnWarning = new BookReturnEmail(
                        _userPresenter.FindUser().Email,
                        (DateTime)addedBook.HasToBeReturned,
                        _book.Author,
                        _book.Title);
                    try
                    {
                        bookReturnWarning.SendWarningEmail();
                    }
                    catch (SmtpException ex)
                    {
                        _exceptionLogger.Log(ex);
                    }

                    MessageBox.Show(Translations.GetTranslatedString("returnUntil") + addedBook.HasToBeReturned);
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show(Translations.GetTranslatedString("cannotTake"));
                }
            }
            else
            {
                MessageBox.Show(Translations.GetTranslatedString("addPicture"));
            }
        }