From 52db1dabf017cb83b1ec61f8f8d68c23bebd17f4 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Mon, 14 Dec 2020 21:33:28 +0330 Subject: [PATCH] bug fix: setting a profile as default for a user causes other users default profile to be removed --- RMuseum/Services/Implementation/RecitationService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index c7255c7a..e2312ce6 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -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);