Add post, fix delete forum, fix null pointer exceptions, min max limist
on database strings
This commit is contained in:
@@ -8,10 +8,23 @@ namespace DAL.Domain
|
||||
{
|
||||
[Key]
|
||||
public int FoorumId { get; set; }
|
||||
|
||||
[MaxLength(length: 128)]
|
||||
[MinLength(length: 1)]
|
||||
public string Title { get; set; }
|
||||
|
||||
[MaxLength(length: 256)]
|
||||
[MinLength(length: 1)]
|
||||
public string Description { get; set; }
|
||||
|
||||
|
||||
[MaxLength(length: 1024)]
|
||||
[MinLength(length: 1)]
|
||||
public string Body { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
[MaxLength(length: 128)]
|
||||
[MinLength(length: 1)]
|
||||
public string Author { get; set; }
|
||||
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Domain
|
||||
{
|
||||
@@ -7,13 +8,22 @@ namespace DAL.Domain
|
||||
{
|
||||
[Key]
|
||||
public int PostId { get; set; }
|
||||
|
||||
[MaxLength(length: 128)]
|
||||
[MinLength(length: 1)]
|
||||
public string Title { get; set; }
|
||||
|
||||
[MaxLength(length: 1024)]
|
||||
[MinLength(length: 1)]
|
||||
public string Body { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
[MaxLength(length: 128)]
|
||||
[MinLength(length: 1)]
|
||||
public string Author { get; set; }
|
||||
|
||||
|
||||
public int ForumId { get; set; }
|
||||
public Foorum Foorum { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace DAL.Helpers
|
||||
|
||||
};
|
||||
ctx.Foorums.Add(foorum);
|
||||
ctx.SaveChanges();
|
||||
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
@@ -30,7 +31,8 @@ namespace DAL.Helpers
|
||||
Title = $"Post {i}",
|
||||
Author = "Karu",
|
||||
Body = $"Pikk sisu {i}",
|
||||
CreationTime = DateTime.Now
|
||||
CreationTime = DateTime.Now,
|
||||
ForumId = foorum.FoorumId
|
||||
};
|
||||
ctx.Posts.Add(post);
|
||||
foorum.Posts.Add(post);
|
||||
|
||||
Reference in New Issue
Block a user