Skip to main content

Posts

Showing posts from September, 2019

NestJS API CRUD Operations With MongoDB

Introduction: NestJS is a framework used to develop server-side applications. NestJS built on top of Node.js frameworks like Express. It is a combination of Progressive Javascript, Object-Oriented Programming, Functional Programming, and Functional Reactive Programming. Nest CLI Installation: Using Nest CLI we are able to generate the NestJS starter project with the default template. To install Nest CLI globally over our system open command prompt and run the command               npm i -g @nestjs/cli Now create a sample project by using Nest CLI command              nest new your_project_name package.json: Now open the package.json file from the sample application created, you can observe few properties like "scripts", "dependencies", and "devDependencies". "dependencies" contains all plugins to be installed and used them to run the application. "devDependencies" contain all plugins to be installed and used them

Mongo Shell Commands Quick Start

Introduction: MongoDB is a document-oriented database, which is classified as a NoSQL database. In MongoDB, tables are called collections and records are called documents. It stores data in JSON format. The reading of data from MongoDB is fast when compared to the Relational Database. Installation: Install MongoDB Community Edition . Here we run MongoDB as a windows server for local development and for learning MongoDB. After successful installation, go to the location "C:\Program Files\MongoDB\Server\4.2\bin" then run "mongod.exe" which starts MongoDB server as windows server. Uses port "27017" as default to serve the requests. Run "mongo.exe" shell command, used as an interface to query the MongoDB. Query Commands: Database: Create a new database by running the command "use your_database_name" on the  "mongo.exe" shell command. To see all the existing databases run the command "show dbs"

Dotnet Core Basic CRUD Operations With MongoDB Using Repository Pattern

Introduction: MongoDB is a document-oriented database, which is classified as a NoSQL database. In MongoDB, tables are called collections and records are called documents. It stores data in JSON format. The reading of data from MongoDB is fast when compared to the Relational Database. But MongoDB doesn't have a relation between the collections. We can't declare NoSQL is better than SQL or vice-versa. So depending on the application requirement either select NoSQL or SQL or Both database. Dotnet Core by default uses an MSSQL database, but it has built-in support for all other types of datastores like MYSQL, ORACLE, and MongoDB, etc. Step 1: Click here  to install the MongoDB community edition. After successful installation go to  "C:\Program Files\MongoDB\Server\4.2\bin" and then run "mongod.exe". Now we started MongoDB server in our local machine on a default port 27017. Step 2: Now open MongoDB shell command "mongo.exe" which is found

Blazor: Blazor Client-Side CRUD Operations (Part 4)

Introduction: In  Part 3  we have discussed on Update Operation using Blazor client-side application. Now we get hands-on Delete Operation in our sample application. Delete Operation: For a delete operation, we use a bootstrap modal for confirmation. Opening and closing of bootstrap in this sample we are going to use bootstrap js. In Blazor not all the operations related to UI can't be done alone with c#, we need to use javascript in few areas. But invokation of the javascript method will be done from the c# method using JavaScript Interoperability. Step 1: Goto "wwwRoot" folder open index.html file add the bootstrap js  links  as shown  below <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.j

Blazor: Blazor Client-Side CRUD Operations (Part 3)

Introduction: In  Part 2  we created a page to fetch all the data in Blazor Client-Side application. Now we are going hands-on UPDATE Operation. Update Operation: Step 1: In the "Pages" folder create a new razor file name it as "EditPlayer.razor".This page is used to update or edit the data in our Balzor Client-Side application. Now to navigate to this new page we need to add Blazor routing with "@page" directives. Add the routing code as below. @page "/player/edit/{PlayerId:int}" "PlayerId:int" is a placeholder in the URL, where the application expects numeric value in that place from the incoming requests. If we try to pass any string value in place of numeric, the application throws an error as no end found with your request. "PlayerId" data get accessed in c# code by creating c# property with same name "PlayerId" and it should be decorated with attribute "[Parameter]" which can observe in

Blazor: Blazor Client-Side CRUD Operations (Part 2)

Introduction: In  Part 1  we have worked on the CREATE Operation page in blazor client-side application. Now here we going to discuss on the READ Operation in blazor client-side application. Read Operation: Step 1: In the "pages" folder, add a new file name as "ShowPlayers.razor". Add players route in the file using "@page" directive as below. @page "/players" Run command "dotnet watch run" and navigate to "http://localhost:5000/players". Step 2: Add the HTML to show all the cricket players that we had created in our application as below <div class="row"> @foreach (var player in players) { <div class="col-sm-4"> <div class="card"> <img src="/images/player.jpg" class="card-img-top"> <div class="card-body"> <h4 Card-title>@player.FirstName @player.LastN

Blazor: Blazor Client-Side CRUD Operations (Part 1)

Introduction: Blazor client-side framework is to build interactive client-side single page web apps which work in all modern web browsers, including mobile browser. The code is written in c# which can run on the browser like javascript frameworks (angular, react, vue etc). In Blazor client-side framework Dotnet Code executed via WebAssembly in the browser runs in the browser's javascript sandbox securely. Specs: 1. Asp.net core 3.0 Preview 2. Blazor (Client-side) 3. Bootstrap 4 4. VisualStudio Code Editor Core Concept: Blazor client-side application sample CRUD (Create, Read, Update, Delete) operations. Let's create a sample application of the Indian cricket team players using the Blazor template. Our final sample looks as follows Create Operation: Step 1: Create Blazor client-side application.  Step by step process to create a blazor template . Step 2: Go to Pages Folder, add a new file name it as "AddPlayer.razor".Now add the follo

Part 2: Share Authentication Cookie - Application Runs Under Another Application

Introduction: In  Part-1  we have implemented SSO with sharing authentication cookie between domain and subdomain binds to an MVC application. Now we implement the sharing authentication cookie between two different applications which runs under another application in IIS Server. For example, ASP.NET Core MVC application is client application shares login cookie to the ASP.NET Core WEB API which is hosted under the MVC application as a child in IIS Server.  To know more about child application runs under another application click here Core Concept: Sharing authentication Cookie between entirely two different applications, but one application runs under other applications in IIS. Create an MVC Application:  Create an MVC application by following  Part-1 , consider it is the main application for registering users and log-in to the application. Create WEB API Application: Now we have to create another application, which runs under the MVC application(created by following Step 1