C
C#2y ago
esther

✅ 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
Angius2y ago
Define "didn't work"
esther
estherOP2y ago
My data didn't update when i tried on swagger
Angius
Angius2y 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
esther
estherOP2y ago
ah so after var blaa = katalogproduk.blaa i need to add something?
Angius
Angius2y ago
var blaa = katalogproduk.blaa just declares a new variable named blaa It doesn't change anything in the entity
esther
estherOP2y ago
so what should i do?
Angius
Angius2y ago
Uh, change the properties of entity?
MODiX
MODiX2y 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
Angius2y ago
See how the value of Bar changes? Do that
esther
estherOP2y ago
what is this mean?
SG97
SG972y 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
esther
estherOP2y ago
should i just delete the second one? Omg thank you i figure it out it works
esther
estherOP2y ago
i'm wrong, i thought it saved on database but it's not. What i miss?
esther
estherOP2y ago
sorry i'm new to this😢
SG97
SG972y ago
start debugging does it find the entity
esther
estherOP2y ago
it works here but not in database, in dabatase data not updated😅
SG97
SG972y ago
use breakpoints how are you handling the case where entity is not found
esther
estherOP2y ago
where i should put my breakpoints? in catch ex?
SG97
SG972y ago
var entity = await _repository.KatalogProduk.FindByCondition....
esther
estherOP2y ago
the entity is found
SG97
SG972y ago
what is the type of _repository and what does SaveAsync do
esther
estherOP2y ago
SaveAsync should save data but i think it didn't work
esther
estherOP2y ago
esther
estherOP2y ago
as irepository wrapper
SG97
SG972y ago
but what does it do exactly SaveAsync I mean
esther
estherOP2y ago
hey sorry i'm back, i added _repository.KatalogProduk.Update(entity); it works
esther
estherOP2y ago
save async
Want results from more Discord servers?
Add your server