Advertisement
Mihai_Preda

Untitled

Dec 8th, 2020
2,750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.75 KB | None | 0 0
  1. using DigitalSchoolGroups.Models;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9.  
  10. namespace DigitalSchoolGroupsPlatform.Models
  11. {
  12.     // Class defining a school group.
  13.     public class Group
  14.     {
  15.         [Key]
  16.         public int Id { get; set; }
  17.  
  18.         [Required(ErrorMessage = "Group title is mandatory!")]
  19.         [StringLength(100, ErrorMessage =
  20.             "Group title cannot contain more than 100 characters!")]
  21.         public string Title { get; set; }
  22.  
  23.         [Required(ErrorMessage = "Group description is mandatory!")]
  24.         [DataType(DataType.MultilineText)]
  25.         public string Description { get; set; }
  26.  
  27.         public DateTime DateCreated { get; set; }
  28.  
  29.         // Foreign Key "CategoryId", mapped to Category Model
  30.         // -> no need to explicitly state [Foreign Key]
  31.         [Required(ErrorMessage = "Group category is mandatory!")]
  32.         public int CategoryId { get; set; }
  33.  
  34.         public string UserId { get; set; }
  35.  
  36.         public virtual ApplicationUser User { get; set; }
  37.  
  38.         // Foreign Key Relationship: One (category) - Many (groups)
  39.         public virtual Category Category { get; set; }
  40.  
  41.         // Foreign Key Relationship: One (group) - Many (messages)
  42.         public virtual ICollection<Message> Messages { get; set; }
  43.  
  44.         public virtual ICollection<ApplicationUser> ApplicationUsers { get; set; }
  45.         //public virtual ICollection<ApplicationUser> Requests { get; set; }
  46.  
  47.         // Declare Categ array for the categories list.
  48.         // Hold as key-value set (SelectListItem).
  49.         public IEnumerable<SelectListItem> Categ { get; set; }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement