bug fix: setting a profile as default for a user causes other users default profile to be removed

This commit is contained in:
Hamid Reza Mohammadi 2020-12-14 21:33:28 +03:30
parent 1456e5bb43
commit 52db1dabf0

View File

@ -1681,7 +1681,7 @@ namespace RMuseum.Services.Implementationa
await _context.SaveChangesAsync();
if(p.IsDefault)
{
foreach(var o in _context.UserRecitationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
foreach(var o in _context.UserRecitationProfiles.Where(o => o.Id != p.Id && o.UserId == p.UserId && o.IsDefault).Select(o => o))
{
o.IsDefault = false;
_context.UserRecitationProfiles.Update(o);
@ -1735,7 +1735,7 @@ namespace RMuseum.Services.Implementationa
await _context.SaveChangesAsync();
if (p.IsDefault)
{
foreach (var o in _context.UserRecitationProfiles.Where(o => o.Id != p.Id && o.IsDefault).Select(o => o))
foreach (var o in _context.UserRecitationProfiles.Where(o => o.Id != p.Id && o.UserId == p.UserId && o.IsDefault).Select(o => o))
{
o.IsDefault = false;
_context.UserRecitationProfiles.Update(o);