dotnet-core_mail-server/MailServer/Database.cs

93 lines
2.4 KiB
C#
Raw Normal View History

2016-11-26 11:11:27 +00:00
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
2016-11-27 17:38:47 +00:00
using System.ComponentModel.DataAnnotations;
2016-11-26 11:11:27 +00:00
using System.IO;
using System.Linq;
using System.Text;
namespace SMTPServer
{
public class MysqlDB : DbContext
{
const string Hostname = "192.168.178.148";
const string DatabaseName = "vmail";
const string Uid = "root";
const string Pwd = "fabian.11";
public DbSet<Domains> Domains { get; set; }
public DbSet<Accounts> Accounts { get; set; }
2016-11-27 17:38:47 +00:00
public DbSet<Folders> Folders { get; set; }
public DbSet<Aliases> Aliases { get; set; }
public DbSet<Mails> Mails { get; set; }
2016-11-26 11:11:27 +00:00
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseMySql(@"Server=" + Hostname + ";database=" + DatabaseName + ";uid=" + Uid + ";pwd=" + Pwd + ";");
}
public class Domains
{
public int Id { get; set; }
public string Domain { get; set; }
public bool IsMail { get; set; }
}
public class Accounts
{
public int Id { get; set; }
2016-11-27 17:38:47 +00:00
[MaxLength(255)]
2016-11-26 11:11:27 +00:00
public string Name { get; set; }
public int Domain { get; set; }
public string Password { get; set; }
2016-11-27 17:38:47 +00:00
public bool CatchAll { get; set; }
2016-11-26 11:11:27 +00:00
public bool Active { get; set; }
}
2016-11-27 17:38:47 +00:00
public class Folders
{
public int Id { get; set; }
public int AccountId { get; set; }
[MaxLength(100)]
public string Name { get; set; }
public int StandardFolder { get; set; }
}
public enum StandardFolders
{
INBOX = 1,
TRASH = 2,
SPAM = 3
}
public class Aliases
{
public int Id { get; set; }
[MaxLength(255)]
public string SourceName { get; set; }
public int SourceDomain { get; set; }
public int DestinationAccount { get; set; }
}
public class Mails
{
public int Id { get; set; }
public int AccountId { get; set; }
public DateTime ReceiveDate { get; set; }
public string Data { get; set; }
[MaxLength(15)]
public string SendedByServerIp { get; set; }
[MaxLength(255)]
public string From { get; set; }
[MaxLength(255)]
public string To { get; set; }
public int Folder { get; set; }
public bool Readed { get; set; }
}
2016-11-26 11:11:27 +00:00
}