Skip to content

Commit

Permalink
Merge pull request #2 from Backiaraj/grid
Browse files Browse the repository at this point in the history
Update the project
  • Loading branch information
rajendranr-5483 authored Jan 1, 2024
2 parents 6ab0a2e + 481aaf9 commit 0fc89ce
Show file tree
Hide file tree
Showing 51 changed files with 530 additions and 1,563 deletions.
6 changes: 4 additions & 2 deletions WebAPI/App.razor → App.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using WebAPI.Data;
using DefaultToolbarItemSample.Data;

namespace WebAPI.Controllers
namespace DefaultToolbarItemSample.Controllers
{
[Route("api/[controller]")]
[ApiController]
Expand Down
6 changes: 3 additions & 3 deletions WebAPI/Data/OrderService.cs → Data/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using WebAPI.Data;
using DefaultToolbarItemSample.Data;

namespace WebAPI.Data
namespace DefaultToolbarItemSample.Data
{
public class OrderService
{
string baseUrl = "http://localhost:50838/";
string baseUrl = "https://localhost:44316/";
public async Task<List<Orders>> GetOrdersAsync()
{
HttpClient http = new HttpClient();
Expand Down
2 changes: 1 addition & 1 deletion WebAPI/Data/Orders.cs → Data/Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Threading.Tasks;

namespace WebAPI.Data
namespace DefaultToolbarItemSample.Data
{
public class EmployeeData
{
Expand Down
8 changes: 3 additions & 5 deletions WebAPI/Data/WeatherForecast.cs → Data/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System;

namespace WebAPI.Data
namespace DefaultToolbarItemSample.Data
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public DateOnly Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string Summary { get; set; }
public string? Summary { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Linq;
using System.Threading.Tasks;

namespace WebAPI.Data
namespace DefaultToolbarItemSample.Data
{
public class WeatherForecastService
{
Expand All @@ -11,14 +7,13 @@ public class WeatherForecastService
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
{
var rng = new Random();
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
}).ToArray());
}
}
Expand Down
17 changes: 9 additions & 8 deletions WebAPI/WebAPI.csproj → DefaultToolbarItemSample.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.14">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Syncfusion.EJ2.Blazor" Version="17.3.0.18-beta" />
<PackageReference Include="Syncfusion.Blazor.Grid" Version="24.1.41" />
<PackageReference Include="Syncfusion.Blazor.Themes" Version="24.1.41" />
</ItemGroup>

</Project>
16 changes: 8 additions & 8 deletions WebAPI/WebAPI.sln → DefaultToolbarItemSample.sln
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29319.158
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAPI", "WebAPI.csproj", "{3C37A581-AC92-4FC2-A3C6-8028603C10A8}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DefaultToolbarItemSample", "DefaultToolbarItemSample.csproj", "{49163226-A426-4403-8FE2-47708EF1F9A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C37A581-AC92-4FC2-A3C6-8028603C10A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C37A581-AC92-4FC2-A3C6-8028603C10A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C37A581-AC92-4FC2-A3C6-8028603C10A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C37A581-AC92-4FC2-A3C6-8028603C10A8}.Release|Any CPU.Build.0 = Release|Any CPU
{49163226-A426-4403-8FE2-47708EF1F9A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49163226-A426-4403-8FE2-47708EF1F9A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49163226-A426-4403-8FE2-47708EF1F9A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49163226-A426-4403-8FE2-47708EF1F9A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D927B854-8D46-454E-B26D-FA85C6589BE9}
SolutionGuid = {88C8F37B-A6E0-48AB-B4A4-BC5899A0EBC4}
EndGlobalSection
EndGlobal
8 changes: 5 additions & 3 deletions WebAPI/Pages/Counter.razor → Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p>Current count: @currentCount</p>
<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
int currentCount = 0;
private int currentCount = 0;

void IncrementCount()
private void IncrementCount()
{
currentCount++;
}
Expand Down
42 changes: 42 additions & 0 deletions Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@page
@model DefaultToolbarItemSample.Pages.ErrorModel

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head>

<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>

</html>
27 changes: 27 additions & 0 deletions Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace DefaultToolbarItemSample.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
9 changes: 5 additions & 4 deletions WebAPI/Pages/FetchData.razor → Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@page "/fetchdata"

@using WebAPI.Data
@using DefaultToolbarItemSample.Data
@inject WeatherForecastService ForecastService

<PageTitle>Weather forecast</PageTitle>

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from a service.</p>
Expand Down Expand Up @@ -37,10 +38,10 @@ else
}

@code {
WeatherForecast[] forecasts;
private WeatherForecast[]? forecasts;

protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
}
30 changes: 15 additions & 15 deletions WebAPI/Pages/Index.razor → Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
@page "/"
@using WebAPI.Data
@using DefaultToolbarItemSample.Data
@inject OrderService Service;

@if (OrdData.Count > 0)
@if (OrdData.Count > 0)
{
<EjsGrid TValue="Orders" @ref="DefaultGrid" DataSource="@OrdData" ModelType="@OrdModel" AllowPaging="true" Toolbar="@(new List<string>() {"Add","Edit","Delete","Update","Cancel"})">
<SfGrid TValue="Orders" DataSource="@OrdData" AllowPaging="true" Toolbar="@(new List<string>() {"Add","Edit","Delete","Update","Cancel"})">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>
<GridEvents OnActionComplete="ActionCompleteHandler" TValue="Orders"></GridEvents>
<GridEvents OnActionComplete="ActionCompleteHandler" TValue="Orders"></GridEvents>
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Orders.OrderID) HeaderText="Order ID" IsPrimaryKey="true" Width="120"></GridColumn>
<GridColumn Field=@nameof(Orders.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field=@nameof(Orders.OrderDate) HeaderText=" Order Date" Format="yMd" Width="130"></GridColumn>
<GridColumn Field=@nameof(Orders.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" Width="130"></GridColumn>
<GridColumn Field=@nameof(Orders.Freight) HeaderText="Freight" Format="C2" Width="120"></GridColumn>
</GridColumns>
</EjsGrid>
</SfGrid>
}

@code{
EjsGrid<Orders> DefaultGrid;
public List<Orders> OrdData = new List<Orders>();
public Orders OrdModel = new Orders();
@code {

public List<Orders> OrdData = new List<Orders>();

protected override async Task OnInitializedAsync()
{
OrdData = await Service.GetOrdersAsync();
OrdData = await Service.GetOrdersAsync();
}
public async void ActionCompleteHandler(ActionEventArgs<Orders> Args)
{
if(Args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Save)
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
var value = OrdData.Find(X => X.OrderID == Args.Data.OrderID);
if (Args.Action == "add")
Expand All @@ -39,9 +39,9 @@
await Service.UpdateOrderAsync(Args.Data.OrderID.ToString(), Args.Data);
}
}
if(Args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Delete)
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Delete)
{
await Service.DeleteOrderAsync(Args.Data.OrderID.ToString());
await Service.DeleteOrderAsync(Args.Data.OrderID.ToString());
}
}
}
}
36 changes: 36 additions & 0 deletions Pages/_Host.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace DefaultToolbarItemSample.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="DefaultToolbarItemSample.styles.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png"/>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.server.js"></script>
</body>
</html>
Loading

0 comments on commit 0fc89ce

Please sign in to comment.