DEV Community

Robertblazor
Robertblazor

Posted on

Blazor app give you some auto calculation

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"
Enter fullscreen mode Exit fullscreen mode

Once this project is created, if you are using VSCode, go ahead and create a new solution file

dotnet new sln -n "BlazorThreadFullStack"
Enter fullscreen mode Exit fullscreen mode

Add a new class library

dotnet new classlib -f net6.0 -n "ThreadsLib"
Enter fullscreen mode Exit fullscreen mode

Add the two projects to the solution

dotnet sln add .\BlazorThreadFullStack\BlazorThreadFullStack.csproj
dotnet sln add .\ThreadsLib\ThreadsLib.csproj
Enter fullscreen mode Exit fullscreen mode

Add a inter-project reference here:

cd .\BlazorThreadFullStack
dotnet add reference ..\ThreadsLib\ThreadsLib.csproj
Enter fullscreen mode Exit fullscreen mode

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

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

Image description

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:


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; }
    }
}
Enter fullscreen mode Exit fullscreen mode

And this is for metric internal threads:


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; }
    }
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay