示例#1
0
        // GET: Authors/Details/5
        public ActionResult Details(int id)
        {
            //if (id == null)
            //{
            //   return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            //Author author = db.Authors.Find(id);
            //if (author == null)
            //{
            //  return HttpNotFound();
            //}
            //return View(author);

            AuthorDetails authorDetails = new AuthorDetails();

            authorDetails.author = db.Authors.FirstOrDefault(z => z.Id == id);
            foreach (Link link in db.Links.ToList())
            {
                if (link.AuthorId == authorDetails.author.Id)
                {
                    BookExtendenAuthor book = new BookExtendenAuthor();
                    Book bookBasic          = db.Books.FirstOrDefault(z => z.Id == link.BookId);
                    book.Id          = bookBasic.Id;
                    book.Name        = bookBasic.Name;
                    book.ImgUrl      = bookBasic.ImgUrl;
                    book.Year        = bookBasic.Year;
                    book.Description = bookBasic.Description;
                    book.Price       = link.Price;
                    book.Units       = link.InStock;

                    authorDetails.Books.Add(book);
                }
            }
            return(View(authorDetails));
        }
示例#2
0
        public void AuthorDetailsShouldErrorWithInvalidName(string invalidName)
        {
            var model = new AuthorDetails()
            {
                FullName = invalidName
            };
            var result = _sut.TestValidate(model);

            result.ShouldHaveValidationErrorFor(x => x.FullName);
        }
示例#3
0
        public void AuthorDetailsShouldErrorWithInvalidEmail(string invalidEmail)
        {
            var model = new AuthorDetails()
            {
                Email = invalidEmail
            };
            var result = _sut.TestValidate(model);

            result.ShouldHaveValidationErrorFor(x => x.Email);
        }
示例#4
0
        // Details

        private void Details(object sender, EventArgs e)
        {
            if (!CheckForSelectedItem())
            {
                return;
            }

            Hide();
            switch (_option)
            {
            case 1:
                var authorDetails = new AuthorDetails(entitiesListBox.SelectedItem as Author);
                authorDetails.Closed += (s, args) => Show();
                authorDetails.ShowDialog();
                break;

            case 2:
                var publisherDetails = new PublisherDetails(entitiesListBox.SelectedItem as Publisher);
                publisherDetails.Closed += (s, args) => Show();
                publisherDetails.ShowDialog();
                break;

            case 3:
                var studentDetails = new StudentDetails(entitiesListBox.SelectedItem as Student);
                studentDetails.Closed += (s, args) => Show();
                studentDetails.ShowDialog();
                break;

            case 4:
                var bookDetails = new BookDetails(entitiesListBox.SelectedItem as Book);
                bookDetails.Closed += (s, args) => Show();
                bookDetails.ShowDialog();
                break;

            case 5:
                var loanDetails = new LoanDetails(entitiesListBox.SelectedItem as Loan);
                loanDetails.Closed += (s, args) => Show();
                loanDetails.ShowDialog();
                break;

            default:
                CommonErrorMessage();
                break;
            }

            RefreshRepositories();
        }
示例#5
0
 public ActionResult Details(int?id)
 {
     if (id.HasValue)
     {
         AuthorDetails authorDetails = new AuthorDetails();
         authorDetails.author = database.Authors.FirstOrDefault(z => z.Id == id);
         authorDetails.books  = new List <Book>();
         foreach (Book book in database.Books.ToList())
         {
             if (book.AuthorID == id)
             {
                 authorDetails.books.Add(book);
             }
         }
         return(View(authorDetails));
     }
     else
     {
         return(Redirect("/Author"));
     }
 }
示例#6
0
        public ActionResult AuthorDetails(string Aid)
        {
            AuthorDetails authorDetailsObj = new AuthorDetails(Aid);

            return(View(authorDetailsObj));
        }