C
C#14mo ago
daisy

✅ Help Me:)

anyone can tell me what's wrong with my code? it didn't work, i tried breakpoints, but i see nothing😅
27 Replies
Angius
Angius14mo ago
Define "didn't work"
daisy
daisy14mo ago
My data didn't update when i tried on swagger
Angius
Angius14mo ago
Well, you never change any properties of entity So you get the entity from the repository, then you make no changes to it, then you save it as it is
daisy
daisy14mo ago
ah so after var blaa = katalogproduk.blaa i need to add something?
Angius
Angius14mo ago
var blaa = katalogproduk.blaa just declares a new variable named blaa It doesn't change anything in the entity
daisy
daisy14mo ago
so what should i do?
Angius
Angius14mo ago
Uh, change the properties of entity?
MODiX
MODiX14mo ago
Angius#1586
REPL Result: Success
using System.Text.Json;

class Foo {
public int Bar { get; set; }
}

var foo = new Foo { Bar = 69 };
Console.WriteLine(JsonSerializer.Serialize(foo));

foo.Bar = 420;
Console.WriteLine(JsonSerializer.Serialize(foo));
using System.Text.Json;

class Foo {
public int Bar { get; set; }
}

var foo = new Foo { Bar = 69 };
Console.WriteLine(JsonSerializer.Serialize(foo));

foo.Bar = 420;
Console.WriteLine(JsonSerializer.Serialize(foo));
Console Output
{"Bar":69}
{"Bar":420}
{"Bar":69}
{"Bar":420}
Compile: 736.720ms | Execution: 67.149ms | React with ❌ to remove this embed.
Angius
Angius14mo ago
See how the value of Bar changes? Do that
daisy
daisy14mo ago
what is this mean?
SG97
SG9714mo ago
you have 2x UpdateKatalogProduk with the same parameters (as the first error states) I'm a bit unsure why you created the second one
daisy
daisy14mo ago
should i just delete the second one? Omg thank you i figure it out it works
daisy
daisy14mo ago
i'm wrong, i thought it saved on database but it's not. What i miss?
daisy
daisy14mo ago
sorry i'm new to this😢
SG97
SG9714mo ago
start debugging does it find the entity
daisy
daisy14mo ago
it works here but not in database, in dabatase data not updated😅
SG97
SG9714mo ago
use breakpoints how are you handling the case where entity is not found
daisy
daisy14mo ago
where i should put my breakpoints? in catch ex?
SG97
SG9714mo ago
var entity = await _repository.KatalogProduk.FindByCondition....
daisy
daisy14mo ago
the entity is found
SG97
SG9714mo ago
what is the type of _repository and what does SaveAsync do
daisy
daisy14mo ago
SaveAsync should save data but i think it didn't work
daisy
daisy14mo ago
daisy
daisy14mo ago
as irepository wrapper
SG97
SG9714mo ago
but what does it do exactly SaveAsync I mean
daisy
daisy14mo ago
hey sorry i'm back, i added _repository.KatalogProduk.Update(entity); it works
daisy
daisy14mo ago
save async