Skip to content

Commit

Permalink
Merge pull request #3 from Backiaraj/datepicker
Browse files Browse the repository at this point in the history
Update the project
  • Loading branch information
rajendranr-5483 authored Oct 13, 2023
2 parents 12f7584 + 8228e9f commit aecc5f8
Show file tree
Hide file tree
Showing 31 changed files with 392 additions and 373 deletions.
14 changes: 14 additions & 0 deletions AddingDatePicker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<PackageReference Include="Syncfusion.Blazor.Calendars" Version="23.1.39" />
<PackageReference Include="Syncfusion.Blazor.Themes" Version="23.1.39" />
</ItemGroup>

</Project>
16 changes: 8 additions & 8 deletions MyBlazorProject.sln → AddingDatePicker.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.29424.173
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyBlazorProject", "MyBlazorProject.csproj", "{3D217D2E-6175-4E79-ADBA-82A1EAA8196F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddingDatePicker", "AddingDatePicker.csproj", "{5798E52C-415E-4EC9-92DE-B8D8D3505319}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3D217D2E-6175-4E79-ADBA-82A1EAA8196F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D217D2E-6175-4E79-ADBA-82A1EAA8196F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D217D2E-6175-4E79-ADBA-82A1EAA8196F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D217D2E-6175-4E79-ADBA-82A1EAA8196F}.Release|Any CPU.Build.0 = Release|Any CPU
{5798E52C-415E-4EC9-92DE-B8D8D3505319}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5798E52C-415E-4EC9-92DE-B8D8D3505319}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5798E52C-415E-4EC9-92DE-B8D8D3505319}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5798E52C-415E-4EC9-92DE-B8D8D3505319}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C9FA3A93-DE4C-4190-BD3A-091E3A884F28}
SolutionGuid = {65FF0191-8A07-4C22-B0B2-033E4AF69A14}
EndGlobalSection
EndGlobal
7 changes: 4 additions & 3 deletions App.razor
Original file line number Diff line number Diff line change
@@ -1,11 +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>
10 changes: 4 additions & 6 deletions Data/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System;

namespace MyBlazorProject.Data
namespace AddingDatePicker.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; }
}
}
}
19 changes: 7 additions & 12 deletions Data/WeatherForecastService.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
using System;
using System.Linq;
using System.Threading.Tasks;

namespace MyBlazorProject.Data
namespace AddingDatePicker.Data
{
public class WeatherForecastService
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
"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());
}
}
}
}
11 changes: 0 additions & 11 deletions MyBlazorProject.csproj

This file was deleted.

4 changes: 3 additions & 1 deletion Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@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>

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 AddingDatePicker.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 AddingDatePicker.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;
}
}
}
16 changes: 0 additions & 16 deletions Pages/Error.razor

This file was deleted.

22 changes: 5 additions & 17 deletions Pages/FetchData.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@page "/fetchdata"

@using MyBlazorProject.Data
@using AddingDatePicker.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,23 +38,10 @@ else
}

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

protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}

@*Add the below snippets inside above tag to apply format, Month picker and watermark
Format="MM yyyy"
Start="@CalendarView.Year"
Depth="@CalendarView.Year"
Placeholder="Choose a Date"
Value="@DateValue"
@code{
public DateTime DateValue { get; set; } = new DateTime(2020, 03, 20);
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
*@
}
16 changes: 6 additions & 10 deletions Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
@page "/"

<div id="wrapper">
@*Add Placeholder="Choose a Date" when Value property is not set*@
@*Add these properties to design Month picker Format="MM yyyy"
Start="@CalendarView.Year"
Depth="@CalendarView.Year"*@
<SfDatePicker TValue="DateTime?"
Value="DateValue"
Min="StartValue"
Max="EndValue"></SfDatePicker>
</div>
<div id="wrapper">
<SfDatePicker TValue="DateTime?"
Value="DateValue"
Min="StartValue"
Max="EndValue"></SfDatePicker>
</div>

@code{
public DateTime DateValue { get; set; } = new DateTime(2020, 03, 20);
Expand Down
17 changes: 8 additions & 9 deletions Pages/_Host.cshtml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
@page "/"
@namespace MyBlazorProject.Pages
@using Microsoft.AspNetCore.Components.Web
@namespace AddingDatePicker.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MyBlazorProject</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="_content/Syncfusion.Blazor/styles/material.css" rel="stylesheet" />
<link href="AddingDatePicker.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>
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
<environment include="Staging,Production">
Expand Down
57 changes: 31 additions & 26 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MyBlazorProject
using AddingDatePicker.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Syncfusion.Blazor;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSyncfusionBlazor();
builder.Services.AddSingleton<WeatherForecastService>();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();

app.UseStaticFiles();

app.UseRouting();

app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.Run();
Loading

0 comments on commit aecc5f8

Please sign in to comment.