Advertisement
Guest User

Untitled

a guest
Nov 26th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. namespace BookShopSystem.Models
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel.DataAnnotations;
  6.  
  7. public class Book
  8. {
  9. private ICollection<Category> categories;
  10.  
  11. private ICollection<Book> relatedBooks;
  12. public Book()
  13. {
  14. this.categories = new HashSet<Category>();
  15. this.relatedBooks = new HashSet<Book>();
  16. }
  17.  
  18. public int Id { get; set; }
  19.  
  20. [MaxLength(50)]
  21. [MinLength(1)]
  22. [Required]
  23. public string Title { get; set; }
  24.  
  25. [MaxLength(1000)]
  26. public string Description { get;set; }
  27.  
  28. [Required]
  29. public int Copies { get; set; }
  30.  
  31. [Required]
  32. public EditionType Edition{ get; set; }
  33.  
  34. [Required]
  35. public decimal Price { get; set; }
  36.  
  37. [Required]
  38. public DateTime? ReleaseDate { get; set; }
  39.  
  40. [Required]
  41. public AgeRestriction AgeRestriction { get; set; }
  42.  
  43. [Required]
  44. public int AuthorId { get; set; }
  45.  
  46. public virtual Author Author { get; set; }
  47.  
  48. public virtual ICollection<Book> RelatedBooks
  49. {
  50. get
  51. {
  52. return this.relatedBooks;
  53. }
  54.  
  55. set
  56. {
  57. this.relatedBooks = value;
  58. }
  59. }
  60.  
  61. public virtual ICollection<Category> Categories
  62. {
  63. get
  64. {
  65. return this.categories;
  66. }
  67.  
  68. set
  69. {
  70. this.categories = value;
  71. }
  72. }
  73. }
  74. }
  75.  
  76. namespace BookShopSystem.Models
  77. {
  78. using System.Collections;
  79. using System.Collections.Generic;
  80. using System.ComponentModel.DataAnnotations;
  81. using System.ComponentModel.DataAnnotations.Schema;
  82.  
  83. public class Author
  84. {
  85. private ICollection<Book> books;
  86.  
  87. public Author()
  88. {
  89. this.books = new HashSet<Book>();
  90. }
  91.  
  92. public int Id { get; set; }
  93.  
  94. [NotMapped]
  95. public string FullName => this.FirstName + " " + this.LastName;
  96.  
  97. [Required]
  98. public string FirstName { get; set; }
  99.  
  100. [Required]
  101. public string LastName { get; set; }
  102.  
  103.  
  104. public virtual ICollection<Book> Books
  105. {
  106. get
  107. {
  108. return this.books;
  109. }
  110. set
  111. {
  112. this.books = value;
  113. }
  114. }
  115. }
  116. }
  117.  
  118. namespace BookShopSystem.Models
  119. {
  120. public enum EditionType
  121. {
  122. Normal = 0,
  123. Promo = 1,
  124. Gold = 2
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement