diff --git a/src/Yavsc.Server/Models/ApplicationUser.cs b/src/Yavsc.Server/Models/ApplicationUser.cs
index f0196af0..7a88f440 100644
--- a/src/Yavsc.Server/Models/ApplicationUser.cs
+++ b/src/Yavsc.Server/Models/ApplicationUser.cs
@@ -72,8 +72,8 @@ namespace Yavsc.Models
/// Billing postal address
///
///
- [ForeignKeyAttribute("PostalAddressId")]
- public virtual Location PostalAddress { get; set; }
+ [ForeignKey("PostalAddressId")]
+ public virtual Location? PostalAddress { get; set; }
public long? PostalAddressId { get; set; }
///
@@ -88,7 +88,7 @@ namespace Yavsc.Models
return this.Id + " " + this.AccountBalance?.Credits.ToString() + this.Email + " " + this.UserName + " $" + this.AccountBalance?.Credits.ToString();
}
- public BankIdentity BankInfo { get; set; }
+ public virtual List BankInfo { get; set; }
public long DiskQuota { get; set; } = 512 * 1024 * 1024;
public long DiskUsage { get; set; } = 0;
diff --git a/src/Yavsc.Server/Models/Bank/BankIdentity.cs b/src/Yavsc.Server/Models/Bank/BankIdentity.cs
index cb08a3a5..eea65d69 100644
--- a/src/Yavsc.Server/Models/Bank/BankIdentity.cs
+++ b/src/Yavsc.Server/Models/Bank/BankIdentity.cs
@@ -58,7 +58,22 @@ namespace Yavsc.Models.Bank
[DisplayName("Clé RIB")]
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;
+ }
+
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/Controllers/Accounting/ManageController.cs b/src/Yavsc/Controllers/Accounting/ManageController.cs
index e54cee73..2833f9d9 100644
--- a/src/Yavsc/Controllers/Accounting/ManageController.cs
+++ b/src/Yavsc/Controllers/Accounting/ManageController.cs
@@ -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 });
}
diff --git a/src/Yavsc/Controllers/Communicating/BlogspotController.cs b/src/Yavsc/Controllers/Communicating/BlogspotController.cs
index af567dd6..8853181d 100644
--- a/src/Yavsc/Controllers/Communicating/BlogspotController.cs
+++ b/src/Yavsc/Controllers/Communicating/BlogspotController.cs
@@ -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]
diff --git a/src/Yavsc/Helpers/UserHelpers.cs b/src/Yavsc/Helpers/UserHelpers.cs
index bb1df0d2..7fba20b8 100644
--- a/src/Yavsc/Helpers/UserHelpers.cs
+++ b/src/Yavsc/Helpers/UserHelpers.cs
@@ -41,7 +41,7 @@ namespace Yavsc.Helpers
b => b.Author
).Where(x => x.Author.Id == posterId && x.Visible);
// BlogIndexKey
- return result.OrderByDescending(p => p.DateCreated);
+ return result;
}
}
}
diff --git a/src/Yavsc/Models/ApplicationDbContext.cs b/src/Yavsc/Models/ApplicationDbContext.cs
index 8e7cded8..8968434c 100644
--- a/src/Yavsc/Models/ApplicationDbContext.cs
+++ b/src/Yavsc/Models/ApplicationDbContext.cs
@@ -51,9 +51,11 @@ namespace Yavsc.Models
builder.Entity().HasKey(x => new { x.OwnerId, x.UserId });
builder.Entity().Property(x => x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
builder.Entity().HasKey(x => new { x.PostId, x.TagId });
+
builder.Entity().HasMany(c => c.Connections);
builder.Entity().Property(u => u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
builder.Entity().Property(u => u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
+
builder.Entity().HasKey(u => new { u.DoesCode, u.UserId });
builder.Entity().HasKey(u => new { u.InstrumentId, u.UserId });
builder.Entity().HasKey(a => new { a.CircleId, a.BlogPostId });
@@ -78,6 +80,7 @@ namespace Yavsc.Models
builder.Entity().Property(a=>a.ParentCode).IsRequired(false);
builder.Entity().HasOne(p => p.Author).WithMany(a => a.Posts);
+
}
// this is not a failback procedure.
diff --git a/src/Yavsc/ViewComponents/BlogIndexViewComponent.cs b/src/Yavsc/ViewComponents/BlogIndexViewComponent.cs
index a8b55058..1ad9f12a 100644
--- a/src/Yavsc/ViewComponents/BlogIndexViewComponent.cs
+++ b/src/Yavsc/ViewComponents/BlogIndexViewComponent.cs
@@ -9,35 +9,33 @@ namespace Yavsc.ViewComponents
public class BlogIndexViewComponent: ViewComponent
{
private readonly ApplicationDbContext _context;
+
public BlogIndexViewComponent(
ApplicationDbContext 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 InvokeAsync(string viewerId, int skip=0, int maxLen=25)
{
long[] usercircles = await _context.Circle.Include(c=>c.Members).
Where(c=>c.Members.Any(m=>m.MemberId == viewerId))
.Select(c=>c.Id).ToArrayAsync();
- IQueryable posts ;
+
var allposts = _context.Blogspot
.Include(b => b.Author)
.Include(p=>p.ACL)
.Include(p=>p.Tags)
.Include(p=>p.Comments)
- .Where(p=>p.AuthorId == viewerId || p.Visible);
+ .Where(p => p.AuthorId == viewerId || p.Visible).ToArray();
- if (usercircles != null) {
- posts = allposts.Where(p=> p.ACL.Count==0 || p.ACL.Any(a=> usercircles.Contains(a.CircleId)))
- ;
- }
- else {
- posts = allposts.Where(p => p.ACL.Count == 0);
- }
+ IEnumerable posts = (usercircles != null) ?
+ allposts.Where(p=> p.ACL.Count==0 || p.ACL.Any(a => usercircles.Contains(a.CircleId)))
+ : 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);
return View("Default", grouped);
diff --git a/src/Yavsc/ViewComponents/CalendarViewComponent.cs b/src/Yavsc/ViewComponents/CalendarViewComponent.cs
index 144ce30f..2a9b4213 100644
--- a/src/Yavsc/ViewComponents/CalendarViewComponent.cs
+++ b/src/Yavsc/ViewComponents/CalendarViewComponent.cs
@@ -18,7 +18,7 @@ namespace Yavsc.ViewComponents
public async Task InvokeAsync (
string htmlFieldName,
- string calId = null)
+ string calId )
{
var minDate = DateTime.Now;
var maxDate = minDate.AddDays(20);
@@ -30,18 +30,6 @@ namespace Yavsc.ViewComponents
return View(model);
}
- public async Task InvokeAsync (
- string htmlFieldName)
- {
- var minDate = DateTime.Now;
- var maxDate = minDate.AddDays(20);
-
- var model = await _manager.CreateViewModelAsync(
- htmlFieldName,
- null, minDate, maxDate
- );
-
- return View(model);
- }
+
}
}
diff --git a/src/Yavsc/ViewModels/Manage/IndexViewModel.cs b/src/Yavsc/ViewModels/Manage/IndexViewModel.cs
index fadb7362..b54bebcc 100644
--- a/src/Yavsc/ViewModels/Manage/IndexViewModel.cs
+++ b/src/Yavsc/ViewModels/Manage/IndexViewModel.cs
@@ -42,7 +42,7 @@ namespace Yavsc.ViewModels.Manage
public string PostalAddress { get; set; }
- public BankIdentity BankInfo { get; set; }
+ public List BankInfo { get; set; }
public long DiskQuota { get; set; }
public long DiskUsage { get; set; }
diff --git a/src/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml b/src/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml
index 219f254d..4c35d4bd 100644
--- a/src/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml
+++ b/src/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml
@@ -163,10 +163,10 @@
Facture acquittée.
}{
- var bi = from.BankInfo;
- if (bi!=null) {
+ if (from.BankInfo!=null) foreach (var bi in from.BankInfo){
À régler par chèque ou par virement bancaire :
+
\begin{center}
\begin{tabular}{|c c c c|}
@if (!string.IsNullOrWhiteSpace(bi.BankCode) && !string.IsNullOrWhiteSpace(bi.WicketCode)