Friday, March 14, 2025

Run Any AI Model with ollama in windows

Steps for install Any model with ollama in local : 
1. Download Olama  and install 


2.  open cmd and run "ollama" command to verify that ollama installed or not.



3. Install models  
    a. find your model and click on it.

   b. copy command and paste into terminal





                      press Enter now your model installed 

Note :Later on same command run your model will run automatically this time it is not downloading it just run 



How To work python with ollama: Run AI Model with Python

Friday, March 7, 2025

๐Ÿ˜ฎCreate Task Scheduler app using AI Agent in just before 2 min ๐Ÿ˜ฎ



Steps to create :
1. use Cline Agent extention in vs code.
2. use api of AI models like.
3. Give prompt to Cline.
4. Work automatically give you clean app.
Note: No need to create any file it will do automatically.

GitHub Repository Viewer

๐Ÿ“Œ GitHub Repository Viewer

Loading...


Git Hub Repo Link Here

Thursday, March 6, 2025

Building a C# Web API with Onion Architecture, CQRS, MediatR & Quartz.NET CRON Jobs

 


Introduction

In modern C# applications, clean architecture plays a crucial role in maintaining scalability and maintainability. In this blog, we will build a C# Web API using Onion Architecture, CQRS, MediatR, and Quartz.NET for scheduling background jobs. This guide will walk you through structuring a project with best practices and SOLID principles.

Why Use Onion Architecture?

Onion Architecture provides a clear separation of concerns by organizing the application into different layers:

  1. Domain Layer → Contains core business logic and entities

  2. Application Layer → Contains CQRS commands, queries, and interfaces

  3. Infrastructure Layer → Handles database, repository pattern, and external integrations

  4. Presentation Layer (API Layer) → Exposes the application as an API

Tech Stack

  • ASP.NET Core Web API for building RESTful APIs

  • Entity Framework Core for database operations

  • CQRS Pattern for separating read & write operations

  • MediatR for in-memory messaging

  • Quartz.NET for CRON Job scheduling

  • SOLID Principles to make the application scalable

    ๐Ÿ“Œ Project Structure

    Your project will be structured as follows:

    Architecture Snippet

    Step 1: Create the Student Model (Domain Layer)

    ๐Ÿ“ Location: Onion.Domain/Models/Student.cs

    Model Snippet

    Step 2: Create CQRS Commands & Queries (Application Layer)

    ✅ Command to Create a Student

    ๐Ÿ“ Location: Onion.Application/Features/Students/Commands/CreateStudentCommand.cs

    Code Snippet

    ✅ Query to Get All Students

    ๐Ÿ“ Location: Onion.Application/Features/Students/Queries/GetAllStudentsQuery.cs

    Code Snippet

    Step 3: Implement Repository (Infrastructure Layer)

    ๐Ÿ“ Location: Onion.Infrastructure/Repositories/StudentRepository.cs

    Code Snippet

    Step 4: Implement CRON Job Using Quartz.NET

    ๐Ÿ“ Location: Onion.Infrastructure/Scheduler/CronJobService.cs

    Code Snippet

    Step 5: Register Everything in Program.cs (API Layer)

    ๐Ÿ“ Location: Onion.API/Program.cs

    Code Snippet

    Conclusion

    By following this guide, you have successfully built a C# Web API with Onion Architecture, CQRS, MediatR, and Quartz.NET CRON Jobs.
    This approach ensures:
    Scalability using Onion Architecture
    Separation of Concerns (SoC)
    Background Job Execution with Quartz.NET
    Better Maintainability with CQRS & MediatR

    ๐Ÿš€ Download Full Project
    Github

๐Ÿ”ฅ "Building a C# Web API with Onion Architecture, CQRS, MediatR & Quartz.NET CRON Jobs Project" ๐Ÿš€


Cover In this:
✅ Onion Architecture ka Overview
✅ CQRS Pattern + MediatR used
✅ Quartz.NET ke sath CRON Jobs
✅ Dependency Injection & SOLID
✅ GitHub :https://github.com/gaganmanakpuria/AddStudentCronJobWithOnionArchitectureWithSOLID


GitHub Repository Viewer

๐Ÿ“Œ GitHub Repository Viewer

Loading...

Tuesday, February 25, 2025

Efficient Parallel Processing in .NET: Using Parallel.ForEach, IServiceScopeFactory, and ConcurrentBag

Parallel processing in .NET can significantly improve performance when dealing with large collections. However, when working with scoped dependencies and thread-safe collections, managing them properly is crucial. This blog explores how to use Parallel.ForEach, IServiceScopeFactory, and ConcurrentBag efficiently.

Why Use Parallel.ForEach?
Parallel.ForEach executes iterations in parallel, utilizing multiple CPU cores to improve performance. However, it does not automatically handle scoped dependencies from IServiceScopeFactory, which is essential when working with services like DbContext in ASP.NET Core.

Why IServiceScopeFactory?
Since DbContext and other scoped services should not be shared across multiple threads, using IServiceScopeFactory ensures each thread gets its own service scope.

Why ConcurrentBag?
When dealing with concurrent operations, ConcurrentBag is a thread-safe collection that allows multiple threads to add or retrieve items without conflicts.


Example:

Code Snippet


Key Takeaways
- Use Parallel.ForEach for performance gains when processing large collections.
- Utilize IServiceScopeFactory to create scoped services inside parallel loops.
- Store results in ConcurrentBag to ensure thread safety when collecting data.
This approach ensures efficient parallel execution while maintaining the integrity of scoped services in .NET. ๐Ÿš€

Friday, February 14, 2025

๐Ÿš€ Oops! Pushed to develop by Mistake? Here’s a Quick Fix! ๐Ÿš€

๐Ÿš€ Oops! Pushed to develop by Mistake? Here’s a Quick Fix! ๐Ÿš€
We've all been there—accidentally pushing changes to the develop branch instead of a feature branch. Before you panic, there's a simple way to undo it gracefully using Git.

๐Ÿ”„ The Quick Fix
If you've mistakenly pushed your latest commit to develop, run the following command: 1️⃣ Save the commit/changes

Code Snippet


๐Ÿ”น What does this do?
✅ Moves the latest commit to staged changes without deleting it.
✅ Allows you to fix things before re-committing or switching branches.

2️⃣ Discard the Commit Completely
If you want to undo the commit entirely (⚠️ This will remove all changes!):

Discard the Last Commit


๐Ÿ”„ Next Steps
Switch to the Correct Branch and Recommit
If you meant to push the changes to a different branch:

Move Changes to Correct Branch


๐Ÿ˜ŠLike that we can revert our mistake๐Ÿ˜Š

Wednesday, February 12, 2025

How to handle when code push accidently in deleted branch

Have you ever pushed your code, only to realize the branch was deleted? ๐Ÿ˜ฑ No worries—your work isn't lost! Git keeps a history of all commits, and you can easily recover your code.
๐Ÿš€ Steps to Recover Your Deleted Branch
1️⃣ Check Your Git Log Even if a branch is deleted, the commits still exist. Run:

Code Snippet

This will show a list of commit hashes with their messages.
2️⃣ Find Your Last Commit Look for the commit related to your deleted branch
3️⃣ Restore Your Branch Once you have the commit hash, recreate the branch:

Code Snippet

Note : Instead of "abc1234" write "your hashcode" and "recovered-branch" write your "new branch name"

๐Ÿ˜ŠNow you can push your code in that branch and you can able to create PR.๐Ÿ˜Š

๐Ÿš€ Agentic Framework 1.0 in .NET: The Power Combo of Semantic Kernel + AutoGen

The AI landscape is shifting fast—from simple prompt-response systems to autonomous, decision-making agents . If you're still building b...