NG MODULE , DIRECTIVES

 15th Day               

Hey Guys, I hope that you are enjoying with my blogs writing and  today's we will create a template project ,Electronic Medical Records (EMR).So let's some introduction                                                

Angular is a framework that is used to create web application. Angular uses typescript to write our business logic and method but browser does not understand typescript. The browser understand JavaScript . so that's why Angular CLI  come into picture. 

                                             

View: app.component.html has html code .In this folder we make user interface.

Model: .

Component: Bind the view and model is called component(app.component.ts). which communicate with anyone like CSS, Module etc.

Module: A group of components is termed as module(app.module.ts).

App.component.spec.ts : It is a testing file.

  1. In this project, First created model like app.model.ts.

app.model.ts(model)

//1. And this my model
export class Patient{
  name:string="";
  age:number=0;
 //2.One patient has list of problem so used an Array..
  problem:Array<Problem> = new Array<Problem>();
}
class Problem{
  //3.for patient it will be many problems...
  description:string="";
}

2.Then after created an user interface(app.component.html).
app.component.html(View)
<!--This is the  User interface
// To bind the text box like Name or Age use directive(ng model)-->
Patient Screen <br>
Name:- <input type="text" [(ngModel)]="patientobj.name" name=""id="txtname"><br>
Age:-  <input type="text" [(ngModel)]="patientobj.age" number=""id="txtage"><br>
<input type="button" (click)="add()" value="Add"/><br>
{{patientobj.name}}<br><!--It is an Expression or interpolation-->
<b>{{patientobj.age}} </b><br>// Here mixing html with angular directives for bold

<table>
  <tr>
    <td>Name</td>
    <td>Age</td>
  </tr>
  <tr *ngFor="let temp of patientobjs">
    <td>{{temp.name}}</td>
    <td>{{temp.age}}</td>
  </tr>
</table>

Explanation: 

  • It may be we go from view to model or model to view or both side-
  • for view to component use ()
  • for component to view use []
  • for two way binding use [()] like [(ngModel)] by using we bind text box with name.

  • input type="text" ngModel=" ngModel="patientobj.name it means that
  • input type(textbox) value bind with name
  • interpolation {{}}
3. After creating model and view .Component which connect to the view and
model ,It will be expose Via the component,  first import the model to component and 
component make object and will be expose to view.
  • view and model type has connection through template URL
app.component.ts(Component)

import { Componentfrom '@angular/core';
// Through below this line, model will be connect
import {Patientfrom "./app.model"
// If code has in current folder then use "./app.model" otherwise "../app.model"
// there has three templates selector, templateurl, styleurl...
@Component({
// this decorator indicates that its an angular components..
// Otherwise it indicates simple code of TypeScript
  selector: 'app-root',
  templateUrl: './app.component.html',
  //its meant to specify the html
  styleUrls: ['./app.component.css']
  //its meant to specify the html
})
export class AppComponent {// This is whole senario is component
  // this Appcomponents color will come above mention, styleUrls: ['./app.component.css']
  patientobj:Patient=new Patient();
  // this patient object tideup with UI(textbox) but now i want a collection to add
  // for that make a list like
  patientobjs:Array<Patient>=new Array<Patient>();
  // this will tideup with table
  // This Array is a stack it means push and pop
  add()// through this method we add current patient
  {
     this.patientobjs.push(this.patientobj);// it will add to the current patient.
     this.patientobj=new Patient();//This will clear my screen
  }// To calling to this add method we write in button(click)="Add()"
}

app.module.ts: (It is the collection of Component)

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

So finally have tried that, textbox data should be set in object and object's data through interpolation it should be show on UI.

Output:


                                 

                          Must watch this video for more details...


                                             Thank You...!

                                                         


ASP.NET MVC Interview Questions Part 3

Hey Guys I hope that you are Enjoying with my Blogs Writing and in this blog we will cover Interview question of ASP.NET MVC Core. So Lets Start....
                              

     Q. What is dependency injection ?
  • Dependency injection is a practice of providing dependent object from outside rather than that the class creating using new keyword.  
  • .NET supports the dependency injection software design pattern, which is a techinque for achieving Inversion of Control between classes and their dependencies.     
    Q. How can we read configuration data from appsettings.json ?
  • To the config data from appsettings.json, We use the IConfiguration object which is Injected by MVC Core Dependency Injection Framework. 
    Q. What is the need of view Data ?
  • View data is a dictionary of objects that are stored and retrieve using strings as keys. It is used to transfer data from Controller to View.
  • Since View Data is a dictionary, it contains key-Value pairs where each key must be a string.
  • View Data only transfer data from controller to view , not vice-versa. It is valid only during the current page. 
    Q. What is the difference between viewdata and viewbag ? 

  • View Data and View Bag are used for the same purpose to transfer data from controller to view. 
  • View Data is nothing but a dictionary of objects and is accessible by strings as key.
  • View Data is the property of Controller that expose an instance of the ViewData Dictionary class.
  • ViewBag is very similar to View data.
  • View Bag is a dynamic property( Dynamic keyword which is introduced in .NET framework 4.0).
  • ViewBag is able to set and get value dynamically .



                                                              Thank You...!


ASP.NET MVC Interview Questions Part 2

 Hey Guys I hope that you are Enjoying with my Blogs Writing and in this blog we will cover Interview question of ASP.NET MVC Core. So Lets Start....

                           

  1. How is the URL structure of MVC Core ?
  2. If the viewname is different from action name how to invoke it?
  3. Defining navigations using anchor tag?
  4. How to pass model to the view ?
  5. What is a strongly typed views  and how do we create them?
  6. How can we change the startup controller name and actin name ?
  7. What is routing ?
  8. How can we pass value in the routes ?
  9. How can we validate the values of the routes ?

Basics of C# and its Installation

  17th Day

Hey Guys, I hope that you are Enjoying with my blogs and Today's we will study about .NET Platform with "C#" Language. Please read, share and Comments.




  .NET 

  • .NET is a free, cross-platform, open source developer platform for building many different types of applications.
  • .NET Core is a cross-platform .NET implementation for websites, servers, and console apps on Windows, Linux, and macOS.
  • With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, and IoT.
  • You can write .NET apps in C#, F#, or Visual Basic.
  • So we will  do study of C#.   

       History:

  • Microsoft family started development of .NET framework the late 1990s originally under the name of Next Generation Windows services.  
  • .NET frame work was released on 13 Feb 2002. The version was called .NET framework 1.0.

   C# :

  • its a programming language, general-purpose, multiprogramming language, encompassing static typing, Strong typing, lexically scoped etc.
  • It was developed around 2000 by Microsoft as part of its .NET.
  • It was designed by Anders Hejisberg.
  • The most recent version is 9.0, Which was released in 2020 in .NET 5.0 and included in Visual Studio 2019 version 16.8.
      Installation of .NET framework:
       Select Community version for downloading purpose.

Then after run the Visual studio we will have to select like:
  • After download just run this application and then create a new project

  • Select Console app(.NET Core) and ok......

so finally Project has been created .....lets run simply.....

You must watch this video for more details...


Thank You...



                               

ASP.NET MVC Interview Questions Part 1

 

   Hey Guys I hope that you are Enjoying with my Blogs Writing and in this blog we will cover Interview question of ASP.NET MVC Core. So Lets Start....

                                   

     Q. What is ASP.NET MVC ?
  • ASP.NET MVC is an open-source cross platform web development to develop web application which is created by Microsoft. Its web development framework combines the features of MVC (Model-View-Controller) architecture.
  • Make it easier to manage complexity by dividing an application into the model, the view, and the controller.
  • When we create a new project then it is created automatically.
       Q. Why do we need Appsettings.json ?
  • Appsettings.json file an application configuration file which is used to store configuration settings such as database connection strings, version no etc.
  • When we create an ASP.NET core web application with an empty project template or MVC templet or Web API Template, then the visual studio automatically creates the appsettings.json file for us as show in the below image.
  • Its is exist in JSON format.

      Q. What is JSON ?
  • JSON is stands for JavaScript object notation it is commonly used to transmitting data in the web application.
  • Its exist in JSON format like name and value.       
    Q. What kind of things go in to wwwroot ?
  • All statics file in our project go into this folder.
  • Statics files like HTML, CSS, and images file etc. stored inside this folder.
      
       

      Q. What does program.cs ?
  • Program.cs file is the entry point of the application. This will be executed first when the application run, There is a public static void main method.
  • Whatever Coe you write inside that method will be executed in that same order.  
      
    Q. What does ConfigureService and Configure method do in Startup.cs ?

                          



    Q. How is the flow of MVC ?
  • MVC is an Architecture pattern which is stands for Model, View and Controller. 
  • If any End users sends the request to the browsers then it first hits to the Controller.
  • And take the data from the model and data put it into the view.
  • And view send as HTML to the Browsers .
  • For Example , Given Below image.


    Q. What are Razor views ?
  • Razor view is a markup syntax which helps us to write code of HTML and Server side in Web page using C# or VB.NET
  • Razor view Engine is general purpose templating engine.
  • The Razor view Syntax starts with @{..  Code...    }.



                                                                Thank You...

SQL SERVER PART II

 Hey Guys, I hope that you are enjoying with my blogs writing and today's we will cover some  "SQL SERVER" Concepts.


Microsoft SQL Server is a relational database management system, or RDBMS, developed and marketed by Microsoft.
As a database server, it is a software products with primary function of storing and retrieving data as requested by other software application.
Initial Releases is April 24, 1989;

   SQL UNION OPERATOR:
  • The union operator is used to combine the result-set of two or more select statements.
  • Every select statements within union have the same number of columns
  • The columns also have similar data type
  • The columns in every select statement must also be in the same order
                         
  • Syntax: 
  • For Distinct Contents: 
        select column_name(s) from table1 union select column(s) from table1;
        For Example: 
                              Input:
    select Id, FirstName, LastName from tblCustomer1


union
select Id, FirstName, LastName from tblexpired



                                Output:


  • For All Contents:
        select column_name(s) from table1 union select column(s) from table1;

          For Example: Input
 select Id, FirstName, LastName from tblCustomer1
union all
select Id, FirstName, LastName from tblexpired
                                Output: Both table has mentioned above and we have taken UNION ALL.
                             Note: We can indicate content by using as normal and expired or anything like:

select 'nomal' as type1, Id, FirstName, LastName from tblCustomer1
union all
select 'expired' as type1,Id, FirstName, LastName from tblexpired

  • GROUP BY:
  •  This statement is often used with aggregate function(COUNT(),MAX(), MIN(),SUM,AVG()).
  • For Example: we have created a table "tblCustomer_ctry" by using this aggregate function we will find its sum of sales of two Countries.
  • "tblCustomer_ctry"    

        Input:  select count(Id), sum(sales),Country from tblCustomer_ctry
                  group by country
      Output:

SUBQUERY: A subquery is a query within another SQL query and embedded within WHERE clause.
  •  It is also called Nested Query.
  • In this case firstly executes its inside queries and after that outside queries.
  • Above two table has created tblCustomer and tblAddress .
            Input: select * from tblAddress
                      where CustomerId_fk in
                      (select Id from tblCustomer)

     Co-related queries : In this Queries ,first executes outside queries and send        the data for inside execution and again send the data from inside to outside. 
            Input: select * from tblAddress
                      where CustomerId_fk in
                      (select Id from tblCustomer where Id=CustomerId_fk)

                                             Thank You...


Hacker Rank Problem Solving on SQL

                                           # PROBLEM-1

Hey Guys , I hope that you are Enjoying with my Blogs writing and this the problem solution of "HACKER RANK SQL ".This solution will definitely will help you.

Problem Statement:  Revising the Select Query I

Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA .

The CITY table is described as follows:


Solution: 

  •  First of all read the problem statements carefully.
  • Write Query to show the all columns for all American cities which is already has in the table "CITY". 
  • And Countrycode is "USA"
  • With population larger than 100000.


             select * from CITY where CountryCode ='USA' AND Population > 100000


                                                    # PROBLEM-2

Problem Statement:  Revising the Select Query II

Thank You...