public IActionResult Post([FromBody] File file) { _db.Files.Add(file); _db.SaveChanges(); return(Created(file)); }
public IActionResult Post([FromBody] File file) { if (file.FileId == 99) { // Special test case for property name case-insensitive Assert.Equal("abc", file.Name); Assert.Equal(DateTimeOffset.Parse("10/28/2021 9:33:26 PM +08:00"), file.CreatedDate); Assert.Equal(DateTimeOffset.Parse("11/1/2021 10:48:12 AM +08:00"), file.DeleteDate); // special string used to verify at test case. return(Ok("PropertyCaseInsensitive")); } _db.Files.Add(file); _db.SaveChanges(); return(Created(file)); }
public FilesController(FilesContext context) { context.Database.EnsureCreated(); if (!context.Files.Any()) { foreach (var file in CreateFiles()) { context.Files.Add(file); } context.SaveChanges(); } _db = context; }