Showing posts with the label .net core

Integrate ChatGPT OpenAI API in .NET Core Console Application from scratch.

  In this Article I am going to demonstrate the integration of ChatGPT OpenAI API in .NET Core Console Application from scratch step by step.      Using ChatGPT API we can integrate the AI in our application just we need to call the API with the help of generating the secret key in ChatGPT developer page following is the steps to generate the secret key with screenshots.  You need to login with the ChatGPT credentials before generating the Secret Key.  On right corner of the page, click on personal icon and then click on View Api Key link On API Keys page click on +Create new secret key button  Then type your desired API key name and then click on   Create secret key button Your API key will be generated then click on copy button to copy the key and save it safely. Congratulation!!! your API key is created for use in console application.        Now we have the secret key with us then we can now move to ChatGPT page and get the code for the integration with console application from

Custom Validation and Class Level validation using Data Annotation in MVC .Net core application

 In Previous article i have demonstrated about " Validations using entity framework data annotation in .Net core MVC " where i have implemented ready made validation types in MVC application. In this article i will be demonstrating about custom validation and class level validation using Data Annotation in MVC .Net core application. The custom validation will be very useful when we need to solve real time scenario where the ready made validation will not work. I also going to show about the class level validation which is also a type of custom kind validation available in data annotation using entity framework. Lets start the implementation, I going to use the same application which i have used in previous article. First we need to add few columns in existing employee table for validation demonstration as below. DateOfBirth DateOfJoin DateOfExit  After adding above fields my model class will look like below using ModelsExample.Attributes; using System; using System.Co

Validations using entity framework data annotation in .Net core MVC

 In previous article we have learnt about working with Drop down in .Net Core MVC . now in this article we will work with the validations using entity framework data annotation. To implement the validation we just need to write minimal code and you are done, you do not need to write extra code for handling validation of your form.  Lets start the implementation, I am going to use the same application for this implementation which i have used in previous article mentioned above. We will use below validation types in this article however there are more validation types available in entity framework data annotation (like Range validation,compare validation,Custom Validation and more)  . Required validation Regular Expression validation String Length validation Max Length validation  First we need to import " _ValidationScriptsPartial " partial class in our view where we need to implement the validation using below syntax. @Html.Partial("_ValidationScriptsPartial")

Working with Drop Down control in .Net Core MVC with steps

In previous articles we have learned about code first approach , Entity migration, crud operation in MVC .NET core, in this article i am going to demonstrate about work with drop down control in .NET Core MVC application with JQuery drop down binding. I am going to use the same application which i have used in crud operation article. So lets start the implementation.       First we need to create the City and State models for that add below classes in ModelExample project.  CityMaster.cs using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text; namespace ModelsExample { [Table("CityMaster")] public class CityMaster { [Key] [Column("Id")] public int Id { get; set; } [Column("Name")] public string Name { get; set; } [Column(" StateMasterId ")] public int StateM