In my Edit modal I have these hidden fields
<input type="hidden" name="Id" value="@Model.Company.Id" />
<input type="hidden" name="CompanyName" value="@Model.Company.CompanyName" />
<input type="hidden" name="Note.Id" value="@Model.Company.Note.Id" />
Here is the model that is returned to my UpdateCompany method: [attachment=0:167vzn0s]Screenshot (16).png[/attachment:167vzn0s] As you can see above the Note.Id is always coming back as NULL to the UpdateCompany method in CompanyAppService.
When I change the name of this field, in the HTML, to "Id", it overlays the "Company Id" column so that does not work.
<input type="hidden" name="Note.Id" value="@Model.Company.Note.Id" />
How can I get the page to return both ID numbers back to my app service method?
2 Answer(s)
-
0
I was able to find one solution. I added line 1 below just before the "MapTo" and that is allowing me to get the "Id" for Note.
input.Note.Id = (int)cmp.Note.Id; input.MapTo(cmp); await _companyRepository.UpdateAsync(cmp);
Please let me know if there is an alternate to this solution. I would prefer the view model send it back to the app service. Thanks!
-
0
Hi,
Since Note is a sub entity, you have to handle it on the client side or server side. If you want to handle it on the client side, you need to manually set your object's note.id field before sending it to server.