Iron
Iron
CC#
Created by Iron on 2/1/2024 in #help
Should i use C# for this idea??
This looked very interesting
13 replies
CC#
Created by Iron on 2/1/2024 in #help
Should i use C# for this idea??
I should mention that the reason i am asking is i have been doing work in PHP lately and i did not touch C# in awhile, i was going to do this all in PHP/Javascript but thats when i was starting to think should i maybe consider like Blazor for this?
13 replies
CC#
Created by MRW419 on 10/27/2023 in #help
❔ What is the problem with this code?
Yes in switch case use
:
:
break with
;
;
8 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
Not sure, first i would prob let telrik know the isPlannable property is bindable by adding a Bindable tag to it( if one still does that )


[Bindable(true)]
public bool IsPlannable { get; set; }


[Bindable(true)]
public bool IsPlannable { get; set; }
` That tells Telerik grid component to treat this property as bindable. Then it can be bound to a checkbox Im not so used to Telerik tho i might be wrong as i said. Then maybe use this:
<GridCheckboxColumn Field=@nameof(CoreEmployee.IsPlannable) CheckBoxOnlySelection="true" Title="Planbar" />
<GridCheckboxColumn Field=@nameof(CoreEmployee.IsPlannable) CheckBoxOnlySelection="true" Title="Planbar" />
` This will create a checkbox in the grid that is bound to the IsPlannable of each employee. Then modify the SaveData method to update the plannableEmployees list instead of updating allEmployees But as i said, if you have a DB, you prob need to make a API call to that DB to read/write, in my case, i usually create the database write/read stuff in my controllers, then i can access data or change using calls to the API. If you are using entity framework core you can do something like this:
`public class EmployeeService : IEmployeeService
{
private readonly ApplicationDbContext _dbContext;

public EmployeeService(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
}

public async Task UpdateEmployee(CoreEmployee employee)
{
var dbEmployee = await _dbContext.CoreEmployees.FindAsync(employee.Id);
dbEmployee.IsPlannable = employee.IsPlannable;
await _dbContext.SaveChangesAsync();
}

public async Task UpdateEmployees(IEnumerable<CoreEmployee> employees)
{
foreach (var employee in employees)
{
var dbEmployee = await _dbContext.CoreEmployees.FindAsync(employee.Id);
dbEmployee.IsPlannable = employee.IsPlannable;
}

await _dbContext.SaveChangesAsync();
}
}
`public class EmployeeService : IEmployeeService
{
private readonly ApplicationDbContext _dbContext;

public EmployeeService(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
}

public async Task UpdateEmployee(CoreEmployee employee)
{
var dbEmployee = await _dbContext.CoreEmployees.FindAsync(employee.Id);
dbEmployee.IsPlannable = employee.IsPlannable;
await _dbContext.SaveChangesAsync();
}

public async Task UpdateEmployees(IEnumerable<CoreEmployee> employees)
{
foreach (var employee in employees)
{
var dbEmployee = await _dbContext.CoreEmployees.FindAsync(employee.Id);
dbEmployee.IsPlannable = employee.IsPlannable;
}

await _dbContext.SaveChangesAsync();
}
}
` Dont listen to everything i say tho because i am not 100%, prob others in this discord who know way more about this. Im just giving you examples
16 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
Then yeah would prob be able to read or write from a controller
16 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
Im talking about if you have users logged in using identity tho might be a better way
16 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
If thats the case you would prob just read the values of the database when rendering the page with the checkboxes and set them to the values of the dB
16 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
Because the way i do that in blazor is i make a call to my api to read or write from database using usermanager, if the value is stored in the users table
16 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
Ohh , well do you have wasm with server or ?
16 replies
CC#
Created by Bamblobski on 10/25/2023 in #help
❔ save checkbox value after refresh
You could save to browser or local storage , session storage would only save it for the current browser session which is what you are probably looking for
16 replies
CC#
Created by Iron on 10/24/2023 in #help
❔ Avoid "Authorizing..." in Blazor Page (Identity)
Thank you so much.
7 replies
CC#
Created by Iron on 10/24/2023 in #help
❔ Avoid "Authorizing..." in Blazor Page (Identity)
This app.razor is from the template i started the project with. Could you give me an example or a link ? Thanks for your answer thats good to know, im just unsure what to do should i remove cascading from app.razor and wrap it around pages that i need it on or ?
7 replies
CC#
Created by Iron on 10/24/2023 in #help
❔ Avoid "Authorizing..." in Blazor Page (Identity)
App.razor:
`<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (context.User.Identity?.IsAuthenticated != true)
{
<RedirectToLogin />
}
else
{
<p role="alert">Du saknar behörighet.</p>
}
</NotAuthorized><Authorizing>
<p>Laddar....</p>
</Authorizing>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Tyvärr, vi hittade inget på denna adress...</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
`<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (context.User.Identity?.IsAuthenticated != true)
{
<RedirectToLogin />
}
else
{
<p role="alert">Du saknar behörighet.</p>
}
</NotAuthorized><Authorizing>
<p>Laddar....</p>
</Authorizing>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Tyvärr, vi hittade inget på denna adress...</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
`
7 replies
CC#
Created by bert on 10/23/2023 in #help
❔ Asp.NET Core Controller and View Problem
Are you creating a controller as template or just adding a new file ? You can add empty controllers , but you can also add controllers with read and write actions etc
46 replies
CC#
Created by AceChewy on 10/23/2023 in #help
❔ Desktop Application Ideas
Also, always finish what you started, or you will end up in a loop yourself
54 replies
CC#
Created by bert on 10/23/2023 in #help
❔ Asp.NET Core Controller and View Problem
Does hes controller look like yours when he create it?
46 replies
CC#
Created by vankata06 on 10/21/2023 in #help
❔ Can you help me with this exercies please.
Upload to GitHub please or share code so i dont have to download something
16 replies
CC#
Created by Azriel on 10/19/2023 in #help
❔ How to fix this problem. I am new to both VS Code and Unity.
Instead of vs code
4 replies
CC#
Created by Azriel on 10/19/2023 in #help
❔ How to fix this problem. I am new to both VS Code and Unity.
If you are new , use visual studio
4 replies
CC#
Created by gauravv on 10/15/2023 in #help
❔ I am trying to run my first C# code but it’s not working
If you are new to c# i recommend vs studio instead of vs code
10 replies