Answer the question
In order to leave comments, you need to log in
How to create an ASP.NET controller for a db?
How to create a controller for a db model?
/* Пользователи */
CREATE TABLE [dbo].[Users] (
[UserID] INT NOT NULL,
[Login] NVARCHAR (25) NOT NULL,
[Password] NVARCHAR (25) NOT NULL,
[FirstName] NVARCHAR (25) NOT NULL,
[SurName] NVARCHAR (25) NOT NULL,
[LastName] NVARCHAR (25) NULL,
[Status] NVARCHAR (25) NOT NULL,
[Balance] INT NULL,
PRIMARY KEY CLUSTERED ([Login] ASC, [UserID] ASC)
);
GO
CREATE UNIQUE NONCLUSTERED INDEX [UserID]
ON [dbo].[Users]([UserID] ASC);
/* События */
CREATE TABLE [dbo].[Events] (
[EventID] INT IDENTITY (1, 1) NOT NULL,
[EventName] NVARCHAR (50) NOT NULL,
[StartTime] DATETIME NOT NULL,
[EndTime] DATETIME NOT NULL,
[Description] NVARCHAR (150) NULL,
[Reward] INT DEFAULT ((0)) NOT NULL,
PRIMARY KEY CLUSTERED ([EventID] ASC)
);
/* Связующий элемент */
CREATE TABLE [dbo].[EventMember] (
[UserID] INT NOT NULL,
[EventID] INT NOT NULL,
PRIMARY KEY CLUSTERED ([UserID] ASC, [EventID] ASC),
CONSTRAINT .[User]].[UserID]]] FOREIGN KEY ([UserID]) REFERENCES [dbo].[Users] ([UserID]),
CONSTRAINT .[Events]].[EventID]]] FOREIGN KEY ([EventID]) REFERENCES [dbo].[Events] ([EventID])
);
public partial class User
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public User()
{
this.EventMembers = new HashSet<EventMember>();
}
public int UserID { get; set; }
public string Login { get; set; }
public string Password { get; set; }
public string FirstName { get; set; }
public string SurName { get; set; }
public string LastName { get; set; }
public string Status { get; set; }
public Nullable<int> Balance { get; set; }
public int EventMemberUserID { get; set; }
public int EventMemberEventID { get; set; }
public int EventMemberUserID1 { get; set; }
public int EventMemberEventID1 { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<EventMember> EventMembers { get; set; }
}
public partial class EventMember
{
public int UserID { get; set; }
public int EventID { get; set; }
public virtual Event Event { get; set; }
public virtual User User { get; set; }
}
public partial class Event
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Event()
{
this.EventMembers = new HashSet<EventMember>();
}
public int EventID { get; set; }
public string EventName { get; set; }
public System.DateTime StartTime { get; set; }
public System.DateTime EndTime { get; set; }
public string Description { get; set; }
public int Reward { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<EventMember> EventMembers { get; set; }
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question