Guest User

Untitled

a guest
Sep 20th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 6.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data.Entity;
  6. using System.ComponentModel;
  7. using System.ComponentModel.DataAnnotations;
  8. using System.Web.Mvc;
  9. using System.Web.Script.Serialization;
  10.  
  11. namespace Timetable.Models
  12. {
  13.     public class TimetableDb : DbContext
  14.     {
  15.         public DbSet<Allocation> Allocations { get; set; }
  16.         public DbSet<Building> Buildings { get; set; }
  17.         public DbSet<Module> Modules { get; set; }
  18.         public DbSet<Request> Requests { get; set; }
  19.         public DbSet<Room> Rooms { get; set; }
  20.         public DbSet<Round> Rounds { get; set; }
  21.         public DbSet<Park> Parks { get; set; }
  22.         public DbSet<Department> Departments { get; set; }
  23.         public DbSet<Lecturer> Lecturers { get; set; }
  24.         public DbSet<Status> Statuses { get; set; }
  25.         public DbSet<RoomType> RoomTypes { get; set; }
  26.         public DbSet<Facility> Facilities { get; set; }
  27.         public DbSet<Week> Weeks { get; set; }
  28.         public DbSet<History> History { get; set; }
  29.     }
  30.  
  31.     public class Allocation
  32.     {
  33.         public int AllocationId { get; set; }
  34.         public int Period { get; set; }
  35.  
  36.         public virtual Request Request { get; set; }
  37.         public virtual Room Room { get; set; }
  38.     }
  39.  
  40.     public class Building
  41.     {
  42.         public int BuildingId { get; set; }
  43.         public string Name { get; set; }
  44.         public string Code { get; set; }
  45.  
  46.         public virtual Park Park { get; set; }
  47.  
  48.         public Object getAsObject()
  49.         {
  50.             return new
  51.             {
  52.                 Name = this.Name,
  53.                 Code = this.Code,
  54.                 Park = this.Park
  55.             };
  56.         }
  57.     }
  58.  
  59.     public class Module
  60.     {
  61.         public int ModuleId { get; set; }
  62.         public string Name { get; set; }
  63.         public string Code { get; set; }
  64.  
  65.         public virtual Department Department { get; set; }
  66.         public virtual ICollection<Lecturer> Lecturers { get; set; }
  67.  
  68.         public Object getAsObject()
  69.         {
  70.             return new
  71.             {
  72.                 ModuleId = this.ModuleId,
  73.                 Name = this.Name,
  74.                 Code = this.Code,
  75.                 Department = this.Department,
  76.                 Lecturers = from l in this.Lecturers
  77.                             select new
  78.                             {
  79.                                 LecturerId = l.LecturerId,
  80.                                 Name = l.Name
  81.                             }
  82.             };
  83.  
  84.         }
  85.     }
  86.  
  87.     public class Request
  88.     {
  89.         public int RequestId { get; set; }
  90.         public int Day { get; set; }
  91.         public int Length { get; set; }
  92.         public int NumStudents { get; set; }
  93.         public int NumRooms { get; set; }
  94.         public int Period { get; set; }
  95.         public bool Priority { get; set; }
  96.         public string SpecReq { get; set; }
  97.  
  98.         public virtual RoomType RoomType { get; set; }
  99.         public virtual Module Module { get; set; }
  100.         public virtual Status Status { get; set; }
  101.         public virtual Round Round { get; set; }
  102.         public virtual ICollection<Room> Rooms { get; set; }
  103.         public virtual ICollection<Facility> Facilities { get; set; }
  104.         public virtual Park Park { get; set; }
  105.         public virtual ICollection<Week> Weeks { get; set; }
  106.         public virtual ICollection<Allocation> Allocations { get; set; }
  107.        
  108.     }
  109.  
  110.     public class Room
  111.     {
  112.         public int RoomId { get; set; }
  113.         public string Code { get; set; }
  114.         public int Capacity { get; set; }
  115.  
  116.         public virtual Building Building { get; set; }
  117.         public virtual RoomType RoomType { get; set; }
  118.         public virtual ICollection<Facility> Facilities { get; set; }
  119.         public virtual ICollection<Request> Requests { get; set; }
  120.  
  121.         public Object getAsObject()
  122.         {
  123.             return new
  124.             {
  125.                 RoomId = RoomId,
  126.                 Code = Code,
  127.                 Capacity = Capacity,
  128.                 Building = Building.getAsObject(),
  129.                 RoomType = RoomType,
  130.                 Facilities = Facilities.Select(x => x.getAsObject())
  131.             };
  132.         }
  133.     }
  134.  
  135.     public class Round
  136.     {
  137.         public int RoundId { get; set; }
  138.         public string Name { get; set; }
  139.         public DateTime StartDate { get; set; }
  140.         public DateTime EndDate { get; set; }
  141.         public bool Active { get; set; }
  142.         public int Semester { get; set; }
  143.         public int Year { get; set; }
  144.     }
  145.  
  146.     public class Park
  147.     {
  148.         public int ParkId { get; set; }
  149.         public string Name { get; set; }
  150.     }
  151.  
  152.     public class Department
  153.     {
  154.         public int DepartmentId { get; set; }
  155.         public string Name { get; set; }
  156.         public string Password { get; set; }
  157.     }
  158.  
  159.     public class Lecturer
  160.     {
  161.         public int LecturerId { get; set; }
  162.         public string Name { get; set; }
  163.  
  164.         public virtual ICollection<Module> Modules { get; set; }
  165.     }
  166.  
  167.     public class Status
  168.     {
  169.         public int StatusId { get; set; }
  170.         public string Name { get; set; }
  171.     }
  172.  
  173.     public class RoomType
  174.     {
  175.         public int RoomTypeId { get; set; }
  176.         public string Name { get; set; }
  177.     }
  178.  
  179.     public class Facility
  180.     {
  181.         public int FacilityId { get; set; }
  182.         public string Name { get; set; }
  183.  
  184.         public virtual ICollection<Request> Requests { get; set; }
  185.         public virtual ICollection<Room> Rooms { get; set; }
  186.  
  187.         public Object getAsObject()
  188.         {
  189.             return new
  190.             {
  191.                 FacilityId = this.FacilityId,
  192.                 Name = this.Name
  193.             };
  194.         }
  195.     }
  196.  
  197.     public class Week
  198.     {
  199.         public int WeekId { get; set; }
  200.         public int Num { get; set; }
  201.  
  202.         public virtual ICollection<Request> Requests { get; set; }
  203.     }
  204.  
  205.     public class History
  206.     {
  207.         public int HistoryId { get; set; }
  208.         public DateTime Date { get; set; }
  209.         public string Action { get; set; }
  210.         public string Message { get; set; }
  211.  
  212.         public virtual Department Department { get; set; }
  213.     }
  214.  
  215. }
Add Comment
Please, Sign In to add comment