Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BookShopSystem.Models
- {
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- public class Book
- {
- private ICollection<Category> categories;
- private ICollection<Book> relatedBooks;
- public Book()
- {
- this.categories = new HashSet<Category>();
- this.relatedBooks = new HashSet<Book>();
- }
- public int Id { get; set; }
- [MaxLength(50)]
- [MinLength(1)]
- [Required]
- public string Title { get; set; }
- [MaxLength(1000)]
- public string Description { get;set; }
- [Required]
- public int Copies { get; set; }
- [Required]
- public EditionType Edition{ get; set; }
- [Required]
- public decimal Price { get; set; }
- [Required]
- public DateTime? ReleaseDate { get; set; }
- [Required]
- public AgeRestriction AgeRestriction { get; set; }
- [Required]
- public int AuthorId { get; set; }
- public virtual Author Author { get; set; }
- public virtual ICollection<Book> RelatedBooks
- {
- get
- {
- return this.relatedBooks;
- }
- set
- {
- this.relatedBooks = value;
- }
- }
- public virtual ICollection<Category> Categories
- {
- get
- {
- return this.categories;
- }
- set
- {
- this.categories = value;
- }
- }
- }
- }
- namespace BookShopSystem.Models
- {
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- public class Author
- {
- private ICollection<Book> books;
- public Author()
- {
- this.books = new HashSet<Book>();
- }
- public int Id { get; set; }
- [NotMapped]
- public string FullName => this.FirstName + " " + this.LastName;
- [Required]
- public string FirstName { get; set; }
- [Required]
- public string LastName { get; set; }
- public virtual ICollection<Book> Books
- {
- get
- {
- return this.books;
- }
- set
- {
- this.books = value;
- }
- }
- }
- }
- namespace BookShopSystem.Models
- {
- public enum EditionType
- {
- Normal = 0,
- Promo = 1,
- Gold = 2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement