This commit is contained in:
Hamid Reza Mohammadi 2025-03-14 10:46:44 +03:30
parent 4b6ca443c0
commit 71a25e89a3

View File

@ -235,25 +235,27 @@ namespace RMuseum.Services.Implementation
}
}
RGenericOption option = await context.Options.Where(o => o.Name == "CategoryWordCountsLastPoetId" && o.RAppUserId == null).SingleOrDefaultAsync();
if (option != null)
if(poetId == 0)
{
option.Value = poetCat.PoetId.ToString();
context.Options.Update(option);
await context.SaveChangesAsync();
}
else
{
RGenericOption newOption = new RGenericOption
RGenericOption option = await context.Options.Where(o => o.Name == "CategoryWordCountsLastPoetId" && o.RAppUserId == null).SingleOrDefaultAsync();
if (option != null)
{
Name = "CategoryWordCountsLastPoetId",
Value = poetCat.PoetId.ToString(),
RAppUserId = null
};
context.Options.Add(newOption);
await context.SaveChangesAsync();
option.Value = poetCat.PoetId.ToString();
context.Options.Update(option);
await context.SaveChangesAsync();
}
else
{
RGenericOption newOption = new RGenericOption
{
Name = "CategoryWordCountsLastPoetId",
Value = poetCat.PoetId.ToString(),
RAppUserId = null
};
context.Options.Add(newOption);
await context.SaveChangesAsync();
}
}
}