refabrique

This commit is contained in:
Paul Schneider 2016-08-02 17:02:38 +02:00
commit 7c603b3cec
17 changed files with 1797 additions and 139 deletions

View file

@ -44,7 +44,7 @@ namespace Yavsc.Controllers
return UserPosts(id);
return View(_context.Blogspot.Include(
b => b.Author
).Where(p => p.visible));
).Where(p => p.Visible));
}
[Route("/Title/{id?}")]
@ -53,7 +53,7 @@ namespace Yavsc.Controllers
{
return View("Index", _context.Blogspot.Include(
b => b.Author
).Where(x => x.title == id).ToList());
).Where(x => x.Title == id).ToList());
}
[Route("/Blog/{id?}")]
@ -63,14 +63,14 @@ namespace Yavsc.Controllers
if (string.IsNullOrEmpty(id))
return View("Index",_context.Blogspot.Include(
b => b.Author
).Where(p => p.visible));
).Where(p => p.Visible));
if (User.IsSignedIn())
return View("Index", _context.Blogspot.Include(
b => b.Author
).Where(x => x.Author.UserName == id).ToList());
return View("Index", _context.Blogspot.Include(
b => b.Author
).Where(x => x.Author.UserName == id && x.visible).ToList());
).Where(x => x.Author.UserName == id && x.Visible).ToList());
}
// GET: Blog/Details/5
[AllowAnonymous]
@ -103,14 +103,14 @@ namespace Yavsc.Controllers
[HttpPost, Authorize(), ValidateAntiForgeryToken]
public IActionResult Create(Blog blog)
{
blog.modified = blog.posted = DateTime.Now;
blog.rate = 0;
blog.Modified = blog.Posted = DateTime.Now;
blog.Rate = 0;
blog.AuthorId = User.GetUserId();
_logger.LogWarning($"Post from: {blog.AuthorId}");
ModelState.ClearValidationState("AuthorId");
if (ModelState.IsValid)
{
blog.posted = DateTime.Now;
blog.Posted = DateTime.Now;
_context.Blogspot.Add(blog);
_context.SaveChanges();
return RedirectToAction("Index");
@ -152,7 +152,7 @@ namespace Yavsc.Controllers
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
if (auth.Result)
{
blog.modified = DateTime.Now;
blog.Modified = DateTime.Now;
_context.Update(blog);
_context.SaveChanges();
ViewData["StatusMessage"] = "Post modified";

View file

@ -31,8 +31,8 @@ namespace Yavsc.Controllers
public ActionResult Index()
{
var latestPosts = _context.Blogspot.Where(
x => x.visible == true
).OrderBy(x => x.modified).Take(25).ToArray();
x => x.Visible == true
).OrderBy(x => x.Modified).Take(25).ToArray();
return View(latestPosts);
}