Blazor app give you some auto calculation
Tags: dotnet, azure, blazor, csharp
Published: 2023-07-31 19:38:26

# BlazorThreadsFullStack
This is a starter project to let you know about databases, Blazor, and how you can create a web page to get to deal with both of them.

For starter, if you are using Visual Studio, go ahead and create a Blazor Server Project, just like me.

Or, if you are using Visual Studio Code, here is the CLI

```
dotnet new blazorserver -f net6.0 -n "BlazorThreadsFullStack"
```
Once this project is created, if you are using VSCode, go ahead and  create a new solution file
```
dotnet new sln -n "BlazorThreadFullStack"
```
Add a new class library
```
dotnet new classlib -f net6.0 -n "ThreadsLib"
```
Add the two projects to the solution
```
dotnet sln add .\BlazorThreadFullStack\BlazorThreadFullStack.csproj
dotnet sln add .\ThreadsLib\ThreadsLib.csproj
```
Add a inter-project reference here:

```
cd .\BlazorThreadFullStack
dotnet add reference ..\ThreadsLib\ThreadsLib.csproj
```

If you like, you can delete the weather forecast files as shown in the project, but I would not show the process here. Here is a youtube video on how to clean up the project:

[How Mr. Tim Corey clean up his project](https://youtu.be/q-ZuYF_O-gk)


I reference this project to this Excel table containing the information of industrial bolts and nuts specs, which is essential for machine shops to reference.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x168bnvpqi1vkl1wnbxd.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aaay7fxeoo3102sq7rbb.png)

Use this two tables as one example, after we figure out the properties, we can have two files to define the model of each category, this is for metric external and metric internal threads:

```csharp

namespace ThreadsLib.Models
{
    [BsonIgnoreExtraElements]
    public class MetricExternal
    {
        [BsonId]
        public ObjectId MEId { get; set; }
        [BsonElement("ID")]
        public int InternalId { get; set; }
        [BsonElement("Size")]
        public double Size { get; set; }
        [BsonElement("ThreadDesignition")]
        public string ThreadDesignition { get; set; }
        [BsonElement("CustomThreadDesignition")]
        public string CustomThreadDesignition { get; set; }
        [BsonElement("Pitch")]
        public double Pitch { get; set; }
        [BsonElement("Class")]
        public string Classification { get; set; }
        [BsonElement("MajorDiaMax")]
        public double MajorDiaMax { get; set; }
        [BsonElement("MajorDiaMin")]
        public double MajorDiaMin { get; set; }
        [BsonElement("PitchDiaMax")]
        public double PitchDiaMax { get; set; }
        [BsonElement("PitchDiaMin")]
        public double PitchDiaMin { get; set; }
        [BsonElement("MinorDiaMax")]
        public double MinorDiaMax { get; set; }
        [BsonElement("MinorDiaMin")]
        public double MinorDiaMin { get; set; }
    }
}
```

And this is for metric internal threads:

```csharp

namespace ThreadsLib.Models
{
    [BsonIgnoreExtraElements]
    public class MetricInternal
    {
        [BsonId]
        public ObjectId MIId { get; set; }
        [BsonElement("ID")]
        public int InternalId { get; set; }
        [BsonElement("ThreadDesignition")]
        public string ThreadDesignition { get; set; }
        [BsonElement("CustomThreadDesignition")]
        public string CustomThreadDesignition { get; set; }
        [BsonElement("Pitch")]
        public double Pitch { get; set; }
        [BsonElement("Class")]
        public string Classification { get; set; }
        [BsonElement("MinorDiaMin")]
        public double MinorDiaMin { get; set; }
        [BsonElement("MinorDiaMax")]
        public double MinorDiaMax { get; set; }
        [BsonElement("PitchDiaMin")]
        public double PitchDiaMin { get; set; }
        [BsonElement("PitchDiaMax")]
        public double PitchDiaMax { get; set; }
        [BsonElement("MajorDiaMin")]
        public double MajorDiaMin { get; set; }
        [BsonElement("MajorDiaMax")]
        public double MajorDiaMax { get; set; }
        [BsonElement("TapDrillBasic")]
        public double TapDrillBasic { get; set; }
        [BsonElement("ThreadDepthMin")]
        public double ThreadDepthMin { get; set; }
        [BsonElement("ThreadRunouts")]
        public double ThreadRunouts { get; set; }
    }
}
```

You may notice that I used MongoDB in this project, yes, exactly

```
dotnet add package MongoDB.Driver --version 2.20.0
dotnet add package Microsoft.Extensions.Caching.Memory --version 6.0.2-mauipre.1.22102.15
dotnet add package Microsoft.Extensions.Configuration.Abstractions --version 6.0.2-mauipre.1.22102.15
```

Follow this pattern, we can go from now to the next step, defining data access layer and establish  our MongoDB.