Skip to content

Commit 0e81083

Browse files
authored
Project file has been added
1 parent fc7eea4 commit 0e81083

34 files changed

+1628
-0
lines changed

App.razor

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
<Router AppAssembly="@typeof(Program).Assembly">
3+
<Found Context="routeData">
4+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
5+
</Found>
6+
<NotFound>
7+
<LayoutView Layout="@typeof(MainLayout)">
8+
<p>Sorry, there's nothing at this address.</p>
9+
</LayoutView>
10+
</NotFound>
11+
</Router>

Data/EmployeeDetails.cs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using System.ComponentModel.DataAnnotations;
6+
using Syncfusion.Blazor.Inputs;
7+
8+
namespace FormBuilder.Data
9+
{
10+
public class EmployeeDetails
11+
{
12+
[Required]
13+
[Display(Name ="First Name")]
14+
[DataType(DataType.Text)]
15+
public string FirstName { get; set; }
16+
[Display(Name = "Last Name")]
17+
[DataType(DataType.Text)]
18+
public string LastName { get; set; }
19+
[Required]
20+
[Display(Name = "Email Address")]
21+
[DataType(DataType.EmailAddress)]
22+
[EmailAddress]
23+
public string Email { get; set; }
24+
[Required]
25+
[Display(Name = "PhoneNumber")]
26+
[DataType(DataType.PhoneNumber)]
27+
[Phone]
28+
public string PhoneNumber { get; set; }
29+
[Required]
30+
[Display(Name = "Date of Birth")]
31+
[DataType(DataType.Date)]
32+
public DateTime? DOB { get; set; }
33+
[Required]
34+
[DataType(DataType.Duration)]
35+
[Display(Name = "Total Experience")]
36+
[Range(0, 20, ErrorMessage = "The Experience range should be 0 to 20")]
37+
public decimal? TotalExperience { get; set; }
38+
[Required]
39+
[Display(Name = "Select a Country")]
40+
[DataType("DropdownList")]
41+
public string Country { get; set; }
42+
[Required]
43+
[Display(Name = "Select a City")]
44+
[DataType("ComboBox")]
45+
public string City { get; set; }
46+
[Required]
47+
[DataType(DataType.MultilineText)]
48+
[Display(Name = "Address")]
49+
public string Address { get; set; }
50+
}
51+
52+
public class Countries
53+
{
54+
public string Name { get; set; }
55+
public string Code { get; set; }
56+
57+
public List<Countries> GetCountries()
58+
{
59+
List<Countries> Country = new List<Countries>
60+
{
61+
new Countries() { Name = "Australia", Code = "AU" },
62+
new Countries() { Name = "United Kingdom", Code = "UK" },
63+
new Countries() { Name = "United States", Code = "US" },
64+
};
65+
return Country;
66+
}
67+
}
68+
public class Cities
69+
{
70+
public string Name { get; set; }
71+
public string Code { get; set; }
72+
public string CountryCode { get; set; }
73+
public List<Cities> GetCities()
74+
{
75+
List<Cities> CityName = new List<Cities>
76+
{
77+
new Cities() { Name = "New York", CountryCode = "US", Code="US-101" },
78+
new Cities() { Name = "Virginia", CountryCode = "US", Code="US-102" },
79+
new Cities() { Name = "Washington", CountryCode = "US", Code="US-103" },
80+
new Cities() { Name = "Victoria", CountryCode = "AU", Code="AU-101" },
81+
new Cities() { Name = "Tasmania", CountryCode = "AU", Code="AU-102" },
82+
new Cities() { Name = "Queensland", CountryCode = "AU", Code="AU-103" },
83+
new Cities() { Name = "London", CountryCode = "UK", Code="UK-101" },
84+
new Cities() { Name = "Manchester", CountryCode = "UK", Code="UK-102" },
85+
new Cities() { Name = "Ashford", CountryCode = "UK", Code="UK-103" }
86+
};
87+
return CityName;
88+
}
89+
}
90+
}

Data/WeatherForecast.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace FormBuilder.Data
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}

Data/WeatherForecastService.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
5+
namespace FormBuilder.Data
6+
{
7+
public class WeatherForecastService
8+
{
9+
private static readonly string[] Summaries = new[]
10+
{
11+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12+
};
13+
14+
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
15+
{
16+
var rng = new Random();
17+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
18+
{
19+
Date = startDate.AddDays(index),
20+
TemperatureC = rng.Next(-20, 55),
21+
Summary = Summaries[rng.Next(Summaries.Length)]
22+
}).ToArray());
23+
}
24+
}
25+
}

FormBuilder.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
9+
<PackageReference Include="Syncfusion.Blazor" Version="18.2.0.57" />
10+
</ItemGroup>
11+
12+
</Project>

FormBuilder.csproj.user

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<RazorPage_SelectedScaffolderID>Microsoft.WebTools.Scaffolding.Core.RazorPageScaffolder</RazorPage_SelectedScaffolderID>
5+
<RazorPage_SelectedScaffolderCategoryPath>root/RazorPage</RazorPage_SelectedScaffolderCategoryPath>
6+
<WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth>
7+
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
8+
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
9+
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
10+
<WebStackScaffolding_LayoutPageFile />
11+
<ShowAllFiles>true</ShowAllFiles>
12+
</PropertyGroup>
13+
</Project>

FormBuilder.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29521.150
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FormBuilder", "FormBuilder.csproj", "{29630493-E009-4E88-8A4E-AD3ECF6F4A42}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{29630493-E009-4E88-8A4E-AD3ECF6F4A42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{29630493-E009-4E88-8A4E-AD3ECF6F4A42}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{29630493-E009-4E88-8A4E-AD3ECF6F4A42}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{29630493-E009-4E88-8A4E-AD3ECF6F4A42}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5352E4FF-D9CA-47FE-80E9-E1667501B45D}
24+
EndGlobalSection
25+
EndGlobal

Pages/Counter.razor

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@page "/counter"
2+
@using Syncfusion.Blazor.Inputs
3+
@using System.ComponentModel.DataAnnotations
4+
5+
<h1>Counter</h1>
6+
7+
<EditForm Model="@m_ModelValue">
8+
<DataAnnotationsValidator />
9+
<ValidationSummary />
10+
@foreach (var field in FieldIdentifiers)
11+
{
12+
@field.Key
13+
@CreateComponent(field.Key, field.Value);
14+
<br />
15+
}
16+
<button type="submit">Submit</button>
17+
</EditForm>
18+
19+
20+
@code {
21+
[Parameter] public User m_ModelValue { get; set; } = new User();
22+
[Parameter] public Dictionary<string, string> FieldIdentifiers { get; set; } = new Dictionary<string, string> { { "FirstName", "string" }, { "Id", "int" } };
23+
public RenderFragment CreateComponent(string fld, string component) => builder =>
24+
{
25+
if (component == "string")
26+
{
27+
builder.OpenComponent(0, typeof(SfTextBox));
28+
}
29+
if (component == "int")
30+
{
31+
builder.OpenComponent(0, typeof(SfNumericTextBox<int?>));
32+
}
33+
builder.CloseComponent();
34+
};
35+
36+
public class User
37+
{
38+
[Required]
39+
public string FirstName { get; set; }
40+
[Required]
41+
public int? Id { get; set; }
42+
}
43+
44+
}

Pages/Error.razor

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/error"
2+
3+
4+
<h1 class="text-danger">Error.</h1>
5+
<h2 class="text-danger">An error occurred while processing your request.</h2>
6+
7+
<h3>Development Mode</h3>
8+
<p>
9+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
10+
</p>
11+
<p>
12+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
13+
It can result in displaying sensitive information from exceptions to end users.
14+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
15+
and restarting the app.
16+
</p>

Pages/FetchData.razor

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@page "/fetchdata"
2+
3+
@using FormBuilder.Data
4+
@inject WeatherForecastService ForecastService
5+
6+
<h1>Weather forecast</h1>
7+
8+
<p>This component demonstrates fetching data from a service.</p>
9+
10+
@if (forecasts == null)
11+
{
12+
<p><em>Loading...</em></p>
13+
}
14+
else
15+
{
16+
<table class="table">
17+
<thead>
18+
<tr>
19+
<th>Date</th>
20+
<th>Temp. (C)</th>
21+
<th>Temp. (F)</th>
22+
<th>Summary</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
@foreach (var forecast in forecasts)
27+
{
28+
<tr>
29+
<td>@forecast.Date.ToShortDateString()</td>
30+
<td>@forecast.TemperatureC</td>
31+
<td>@forecast.TemperatureF</td>
32+
<td>@forecast.Summary</td>
33+
</tr>
34+
}
35+
</tbody>
36+
</table>
37+
}
38+
39+
@code {
40+
private WeatherForecast[] forecasts;
41+
42+
protected override async Task OnInitializedAsync()
43+
{
44+
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
45+
}
46+
}

0 commit comments

Comments
 (0)