1- @page " /authordetails"
1+ @* @ page "/authordetails" *@
22@page " /authordetails/{id}"
33@using BookManagementApp .Models
44@using BookManagementApp .Services
55@using System .Text .Json
66@inject NavigationManager Navigation
77@inject AuthorService authorService
88
9- @if (string .IsNullOrEmpty (Id ))
9+ @* @ if(string.IsNullOrEmpty(Id))
1010{
1111 <PageTitle>Add New Author</PageTitle>
1212 <h3>Author management</h3>
1313 <p>Add details for a new author</p>
1414}
1515else
16- {
16+ { *@
1717 <PageTitle >Edit Author</PageTitle >
1818 <h3 >Author details</h3 >
1919 <p >Edit details for a existing author</p >
20- }
20+ @* } *@
2121
2222<div class =" row" >
2323 <EditForm Model =" @author" OnValidSubmit =" @HandleValidRequest" OnInvalidSubmit =" @HandleFailedRequest" >
9191
9292 protected async override Task OnInitializedAsync ()
9393 {
94- if (! string .IsNullOrEmpty (Id ))
95- {
94+ @* if (!string.IsNullOrEmpty(Id))
95+ { *@
9696 var authorId = Convert .ToInt32 (Id );
9797 var apiAuthor = await authorService .GetAuthorByIdAsync (authorId );
9898 if (apiAuthor != null )
@@ -101,11 +101,11 @@ else
101101 StateHasChanged ();
102102 Console .WriteLine ($" Fetched author: {JsonSerializer .Serialize (author )}" );
103103 }
104- }
105- else
106- {
104+ @* } *@
105+ @* else
106+ { *@
107107 // Code for adding a new author goes here
108- if (string .IsNullOrEmpty (Id ))
108+ @* if (string.IsNullOrEmpty(Id))
109109 {
110110 var result = await authorService.AddAuthorAsync2(author);
111111
@@ -116,20 +116,20 @@ else
116116 }
117117 else
118118 {
119- author .Id = Convert .ToInt32 (Id ); // Add this line
119+ author.id = Convert.ToInt32(Id); // Add this line
120120 var result = await authorService.UpdateAuthorAsync(author);
121121
122122 if (result)
123123 Navigation.NavigateTo("/authors");
124124 else
125125 Message = "Failed to update author";
126126 }
127- }
127+ } *@
128128 }
129129
130130 protected async void HandleValidRequest ()
131131 {
132- if (string .IsNullOrEmpty (Id ))
132+ @* if (string.IsNullOrEmpty(Id))
133133 {
134134 var result = await authorService.AddAuthorAsync2(author);
135135
@@ -139,14 +139,14 @@ else
139139 Message = "Failed to add author";
140140 }
141141 else
142- {
143- author .Id = Convert .ToInt32 (Id ); // Add this line
142+ { *@
143+ author .id = Convert .ToInt32 (Id ); // Add this line
144144 var result = await authorService .UpdateAuthorAsync (author );
145145
146146 if (result )
147147 Navigation .NavigateTo (" /authors" );
148148 else
149149 Message = " Failed to update author" ;
150- }
150+ @* } *@
151151 }
152152}
0 commit comments