a blog index

This commit is contained in:
Paul Schneider
2023-04-01 15:03:48 +01:00
parent 2562c9a569
commit 02d80795ca
10 changed files with 47 additions and 45 deletions

View File

@ -332,17 +332,15 @@ namespace Yavsc.Controllers
var user = _dbContext.Users.Include(u=>u.BankInfo)
.Single(u=>u.Id == uid);
if (user.BankInfo != null)
{
model.Id = user.BankInfo.Id;
_dbContext.Entry(user.BankInfo).State = EntityState.Detached;
_dbContext.Update(model);
}
else {
user.BankInfo = model;
_dbContext.Update(user);
}
await _dbContext.SaveChangesAsync();
if (user.BankInfo.Any(
bi => bi.Equals(model)
)) return BadRequest(new { message = "data already present" });
user.BankInfo.Add(model);
_dbContext.Update(user);
await _dbContext.SaveChangesAsync();
}
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetBankInfoSuccess });
}

View File

@ -67,7 +67,7 @@ namespace Yavsc.Controllers
{
string posterId = (await _context.Users.SingleOrDefaultAsync(u=>u.UserName == userName))?.Id ?? null ;
var result = _context.UserPosts(posterId, User.Identity.Name);
return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().Skip(pageLen*pageNum).Take(pageLen).GroupBy(p=> p.Title ));
return View("Index", result.ToArray().Skip(pageLen*pageNum).Take(pageLen).OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=> p.Title ));
}
// GET: Blog/Details/5
[AllowAnonymous]