Saturday, 22 February 2025

Quickest way to copy text from image in just 5 sec #Window #offline

I will show Quickest way how to copy text from image in just 5 sec in Window by OS using Snipping Tool. No need to install any tool. 1 : Open Snipping tool. Note "Camera" icon selected, not video icon. 2 : New : Select area you want to extract text 3 : In Snipping tool, from Header select 'rounded square' icon. 3rd icon from last. on hover "Text Icon" display. If not display then maximise snipping. 4 : Withing few select of process, "Copy all text" option will be available. Click on it. You text is copied on clipboard. Paste wherre ever you want.




Monday, 17 February 2025

How to add Github profile on Linkedin


How to add Github account profile to LinkedIn prfile for better profile visibility.

Steps : 
Open LinkedIn
1 : Navigate to Profile section.
2 : Click on "Add profile section".
3 : Pop-up modal will open,  expand "Recommended.
4 : Click on "Add featured" and new Fatured layout will be load.
5 : Click on +  plus icon. then select "Add a link"
6 : Now login to Github and navigate to your profile.
7 : Copy profile page URL and paste in text box opened in step 5 and click "Add"
In Title field : use can specify like "Github Profile" or any thing 
8 : https://www.linkedin.com/feed/

For step by step process, you can go through bellow video

Thursday, 12 December 2024

How to Integrate Swagger in .NetCore Web API project

Aim: Integrate Swagger in .NetCore Web API project
 (Visual Studio 2022 +  .NET 6)
 
1: Create new Web API project (without swagger built in integration)
We are not using OpenAPI in built from Demo.
We do all manually for better understanding
2: Install NuGet Package: SwashbuvkleAspNetCore
3: Update Program.cs file
    Builder.Services.AddSwaggerGen();
4:    Register Middleware
app.UseSwagger();
app.UseSwaggerUI()
 
To load swagger when we run project/ when we run project, landing page is swagger, 
need to update launchsetting.json file.
- set launchUrl to "swagger"

For step by step detail, watch video.

Sunday, 1 December 2024

In LinkedIn profile section, How to add Stackoverflow profile

Sunday, 26 May 2024

C# Custom Data Data Annotation - Validators with Example

 (1) What is Custom Data Annotations in C# model class? 

       When Custom Data Annotation useful? 

Ans : You have learn and regular and basic Data Annotation for validaion.

We  can apply validation at Model (POCO) class by using appropriate attribute.
Like Required, StringLength, MaxLength, EmailAddress and many more.

Now add following code for UI side
@model WebAppCustomDataAnnotation.Models.Student
<h2>Create</h2>

@using (Html.BeginForm()) 
{    
    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
            @Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
        </div>

        <div class="form-group">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
}


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

In this post we focus on custom Data Annotation.


When default attribute not sufficient to achieve our validation.
When validation is not achievable by Microsoft provided attribute


For example - We have a Student table in Data base.


Before saving record, We need to check EMail value must be unique.

But this is not achievable my available basic attribute.
But to tackle this limitation, we have Custom Data Annotation.
Assume system already contain email - "name@company.com"
If user try to insert same value again then validation must be there.
and error message will be prompt.

Create new class :

UniqueEmailAttribute and inherit ValidationAttribute.

public class UniqueEmailAttribute : ValidationAttribute { protected override ValidationResult IsValid(object _value, ValidationContext validationContext) { if (_value != null && _value.ToString() == "name@company.com") { return new ValidationResult(ErrorMessage = "Email address already exist"); } return ValidationResult.Success; } }


Here we have create Custom Data Annotation. 
It contain IsValid() method.
We have override this method and added logic to check existing value.

Provided Email value come at first parameter : object _value

If input email value is "name@company.com" then
it will return Error message.

Otherwise will return Success.(Validation passed)

You can provide error message as per your requirement.

This Method return ValidationResult.

Final Step :
Now add this created custom data annotation as attribute 
at Email property in Student class.
[Required(ErrorMessage = "Email address is required.")]
[UniqueEmail]
public string Email { get; set; }


Here error message is hard coded. but in real scenario it never happen.
So error message must be dynamicaly need to set.
In Student model - along with custom attribute "UniqueEmail", 
need to add ErrorMessage as shown in bellow.


As Error message set in Attribute, will show in bellow display 
when in Email field value added and "Create" button clicked as shown bellow.








Saturday, 26 August 2023

SQL interview question Part-2

 Note :  All sql related question related to SQL Server.

(1) In SQL : How to swap column values​​ ?










Ans : 
update #tempSwap set EMPNAME = DEPT,DEPT = EMPNAME;