a blog index
This commit is contained in:
@ -72,8 +72,8 @@ namespace Yavsc.Models
|
|||||||
/// Billing postal address
|
/// Billing postal address
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[ForeignKeyAttribute("PostalAddressId")]
|
[ForeignKey("PostalAddressId")]
|
||||||
public virtual Location PostalAddress { get; set; }
|
public virtual Location? PostalAddress { get; set; }
|
||||||
public long? PostalAddressId { get; set; }
|
public long? PostalAddressId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -88,7 +88,7 @@ namespace Yavsc.Models
|
|||||||
return this.Id + " " + this.AccountBalance?.Credits.ToString() + this.Email + " " + this.UserName + " $" + this.AccountBalance?.Credits.ToString();
|
return this.Id + " " + this.AccountBalance?.Credits.ToString() + this.Email + " " + this.UserName + " $" + this.AccountBalance?.Credits.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BankIdentity BankInfo { get; set; }
|
public virtual List<BankIdentity> BankInfo { get; set; }
|
||||||
|
|
||||||
public long DiskQuota { get; set; } = 512 * 1024 * 1024;
|
public long DiskQuota { get; set; } = 512 * 1024 * 1024;
|
||||||
public long DiskUsage { get; set; } = 0;
|
public long DiskUsage { get; set; } = 0;
|
||||||
|
@ -58,7 +58,22 @@ namespace Yavsc.Models.Bank
|
|||||||
[DisplayName("Clé RIB")]
|
[DisplayName("Clé RIB")]
|
||||||
public int BankedKey { get; set; }
|
public int BankedKey { get; set; }
|
||||||
|
|
||||||
|
public virtual ApplicationUser User { get; set; }
|
||||||
|
|
||||||
|
public string UserId { get; set; }
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
if (obj==null) return false;
|
||||||
|
if (! typeof(BankIdentity).IsAssignableFrom(obj.GetType())) return false;
|
||||||
|
BankIdentity tobj = (BankIdentity)obj;
|
||||||
|
return tobj.IBAN == IBAN &&
|
||||||
|
tobj.BIC == BIC &&
|
||||||
|
tobj.AccountNumber == AccountNumber &&
|
||||||
|
tobj.BankedKey == BankedKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -332,17 +332,15 @@ namespace Yavsc.Controllers
|
|||||||
var user = _dbContext.Users.Include(u=>u.BankInfo)
|
var user = _dbContext.Users.Include(u=>u.BankInfo)
|
||||||
.Single(u=>u.Id == uid);
|
.Single(u=>u.Id == uid);
|
||||||
|
|
||||||
if (user.BankInfo != null)
|
if (user.BankInfo.Any(
|
||||||
{
|
bi => bi.Equals(model)
|
||||||
model.Id = user.BankInfo.Id;
|
)) return BadRequest(new { message = "data already present" });
|
||||||
_dbContext.Entry(user.BankInfo).State = EntityState.Detached;
|
|
||||||
_dbContext.Update(model);
|
user.BankInfo.Add(model);
|
||||||
}
|
|
||||||
else {
|
_dbContext.Update(user);
|
||||||
user.BankInfo = model;
|
|
||||||
_dbContext.Update(user);
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
|
||||||
await _dbContext.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetBankInfoSuccess });
|
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.SetBankInfoSuccess });
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
string posterId = (await _context.Users.SingleOrDefaultAsync(u=>u.UserName == userName))?.Id ?? null ;
|
string posterId = (await _context.Users.SingleOrDefaultAsync(u=>u.UserName == userName))?.Id ?? null ;
|
||||||
var result = _context.UserPosts(posterId, User.Identity.Name);
|
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
|
// GET: Blog/Details/5
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
@ -41,7 +41,7 @@ namespace Yavsc.Helpers
|
|||||||
b => b.Author
|
b => b.Author
|
||||||
).Where(x => x.Author.Id == posterId && x.Visible);
|
).Where(x => x.Author.Id == posterId && x.Visible);
|
||||||
// BlogIndexKey
|
// BlogIndexKey
|
||||||
return result.OrderByDescending(p => p.DateCreated);
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,11 @@ namespace Yavsc.Models
|
|||||||
builder.Entity<Contact>().HasKey(x => new { x.OwnerId, x.UserId });
|
builder.Entity<Contact>().HasKey(x => new { x.OwnerId, x.UserId });
|
||||||
builder.Entity<DeviceDeclaration>().Property(x => x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
|
builder.Entity<DeviceDeclaration>().Property(x => x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
|
||||||
builder.Entity<BlogTag>().HasKey(x => new { x.PostId, x.TagId });
|
builder.Entity<BlogTag>().HasKey(x => new { x.PostId, x.TagId });
|
||||||
|
|
||||||
builder.Entity<ApplicationUser>().HasMany<ChatConnection>(c => c.Connections);
|
builder.Entity<ApplicationUser>().HasMany<ChatConnection>(c => c.Connections);
|
||||||
builder.Entity<ApplicationUser>().Property(u => u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
|
builder.Entity<ApplicationUser>().Property(u => u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
|
||||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
|
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
|
||||||
|
|
||||||
builder.Entity<UserActivity>().HasKey(u => new { u.DoesCode, u.UserId });
|
builder.Entity<UserActivity>().HasKey(u => new { u.DoesCode, u.UserId });
|
||||||
builder.Entity<Instrumentation>().HasKey(u => new { u.InstrumentId, u.UserId });
|
builder.Entity<Instrumentation>().HasKey(u => new { u.InstrumentId, u.UserId });
|
||||||
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a => new { a.CircleId, a.BlogPostId });
|
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a => new { a.CircleId, a.BlogPostId });
|
||||||
@ -78,6 +80,7 @@ namespace Yavsc.Models
|
|||||||
|
|
||||||
builder.Entity<Activity>().Property(a=>a.ParentCode).IsRequired(false);
|
builder.Entity<Activity>().Property(a=>a.ParentCode).IsRequired(false);
|
||||||
builder.Entity<BlogPost>().HasOne(p => p.Author).WithMany(a => a.Posts);
|
builder.Entity<BlogPost>().HasOne(p => p.Author).WithMany(a => a.Posts);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is not a failback procedure.
|
// this is not a failback procedure.
|
||||||
|
@ -9,35 +9,33 @@ namespace Yavsc.ViewComponents
|
|||||||
public class BlogIndexViewComponent: ViewComponent
|
public class BlogIndexViewComponent: ViewComponent
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public BlogIndexViewComponent(
|
public BlogIndexViewComponent(
|
||||||
ApplicationDbContext context)
|
ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renders blog index ofr the specified user by name
|
// Renders blog index ofr the specified user by name,
|
||||||
|
// grouped by title
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string viewerId, int skip=0, int maxLen=25)
|
public async Task<IViewComponentResult> InvokeAsync(string viewerId, int skip=0, int maxLen=25)
|
||||||
{
|
{
|
||||||
long[] usercircles = await _context.Circle.Include(c=>c.Members).
|
long[] usercircles = await _context.Circle.Include(c=>c.Members).
|
||||||
Where(c=>c.Members.Any(m=>m.MemberId == viewerId))
|
Where(c=>c.Members.Any(m=>m.MemberId == viewerId))
|
||||||
.Select(c=>c.Id).ToArrayAsync();
|
.Select(c=>c.Id).ToArrayAsync();
|
||||||
IQueryable<BlogPost> posts ;
|
|
||||||
var allposts = _context.Blogspot
|
var allposts = _context.Blogspot
|
||||||
.Include(b => b.Author)
|
.Include(b => b.Author)
|
||||||
.Include(p=>p.ACL)
|
.Include(p=>p.ACL)
|
||||||
.Include(p=>p.Tags)
|
.Include(p=>p.Tags)
|
||||||
.Include(p=>p.Comments)
|
.Include(p=>p.Comments)
|
||||||
.Where(p=>p.AuthorId == viewerId || p.Visible);
|
.Where(p => p.AuthorId == viewerId || p.Visible).ToArray();
|
||||||
|
|
||||||
if (usercircles != null) {
|
IEnumerable<BlogPost> posts = (usercircles != null) ?
|
||||||
posts = allposts.Where(p=> p.ACL.Count==0 || p.ACL.Any(a=> usercircles.Contains(a.CircleId)))
|
allposts.Where(p=> p.ACL.Count==0 || p.ACL.Any(a => usercircles.Contains(a.CircleId)))
|
||||||
;
|
: allposts.Where(p => p.ACL.Count == 0);
|
||||||
}
|
|
||||||
else {
|
|
||||||
posts = allposts.Where(p => p.ACL.Count == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = posts.OrderByDescending( p=> p.DateCreated).ToArray();
|
var data = posts.OrderByDescending( p=> p.DateCreated);
|
||||||
var grouped = data.GroupBy(p=> p.Title).Skip(skip).Take(maxLen);
|
var grouped = data.GroupBy(p=> p.Title).Skip(skip).Take(maxLen);
|
||||||
|
|
||||||
return View("Default", grouped);
|
return View("Default", grouped);
|
||||||
|
@ -18,7 +18,7 @@ namespace Yavsc.ViewComponents
|
|||||||
|
|
||||||
public async Task<IViewComponentResult> InvokeAsync (
|
public async Task<IViewComponentResult> InvokeAsync (
|
||||||
string htmlFieldName,
|
string htmlFieldName,
|
||||||
string calId = null)
|
string calId )
|
||||||
{
|
{
|
||||||
var minDate = DateTime.Now;
|
var minDate = DateTime.Now;
|
||||||
var maxDate = minDate.AddDays(20);
|
var maxDate = minDate.AddDays(20);
|
||||||
@ -30,18 +30,6 @@ namespace Yavsc.ViewComponents
|
|||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
public async Task<IViewComponentResult> InvokeAsync (
|
|
||||||
string htmlFieldName)
|
|
||||||
{
|
|
||||||
var minDate = DateTime.Now;
|
|
||||||
var maxDate = minDate.AddDays(20);
|
|
||||||
|
|
||||||
var model = await _manager.CreateViewModelAsync(
|
|
||||||
htmlFieldName,
|
|
||||||
null, minDate, maxDate
|
|
||||||
);
|
|
||||||
|
|
||||||
return View(model);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ namespace Yavsc.ViewModels.Manage
|
|||||||
|
|
||||||
public string PostalAddress { get; set; }
|
public string PostalAddress { get; set; }
|
||||||
|
|
||||||
public BankIdentity BankInfo { get; set; }
|
public List<BankIdentity> BankInfo { get; set; }
|
||||||
public long DiskQuota { get; set; }
|
public long DiskQuota { get; set; }
|
||||||
public long DiskUsage { get; set; }
|
public long DiskUsage { get; set; }
|
||||||
|
|
||||||
|
@ -163,10 +163,10 @@
|
|||||||
Facture acquittée.
|
Facture acquittée.
|
||||||
}{ </text>
|
}{ </text>
|
||||||
|
|
||||||
var bi = from.BankInfo;
|
if (from.BankInfo!=null) foreach (var bi in from.BankInfo){
|
||||||
if (bi!=null) {
|
|
||||||
<text>À régler par chèque ou par virement bancaire :
|
<text>À régler par chèque ou par virement bancaire :
|
||||||
|
|
||||||
|
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tabular}{|c c c c|}
|
\begin{tabular}{|c c c c|}
|
||||||
@if (!string.IsNullOrWhiteSpace(bi.BankCode) && !string.IsNullOrWhiteSpace(bi.WicketCode)
|
@if (!string.IsNullOrWhiteSpace(bi.BankCode) && !string.IsNullOrWhiteSpace(bi.WicketCode)
|
||||||
|
Reference in New Issue
Block a user