Posts

Asp.net core MVC Session

Image
  public class MyController : Controller {   // Define an action method to handle the AJAX request   [HttpPost] // or [HttpGet] depending on your configuration   public ActionResult DropdownChanged(string selectedValue)   {     // Perform any necessary actions based on the selected value     // and return the updated data or a JSON response.     // Example logic:     if (selectedValue == "option1")     {       // Do something when Option 1 is selected     }     else if (selectedValue == "option2")     {       // Do something when Option 2 is selected     }     else if (selectedValue == "option3")     {       // Do something when Option 3 is selected     }     // Return the updated data or a JSON response.   } } <select id="myDropdown">   <option value="option1">Option ...

Pub Sub Service in asp.net core

 Controller using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc; using QHSE.Services.Common; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs.Extensions.WebPubSub; using Azure.Messaging.WebPubSub; using Microsoft.Extensions.Configuration; using System.Threading.Tasks; using System; using Microsoft.Graph; namespace QHSE.API.Controllers.Common {     [Route("api/alerts")]     [ApiController]     public class AlertController : ControllerBase     {         private readonly IAlertService _alertService;         private readonly WebPubSubServiceClient _serviceClient;         private readonly string _hubName;         public AlertController(IAlertService alertService, IConfiguration configuration)         {             _alertService = ...

Unit test X Unit simple way generate

  Unit Test Boilerplate Generator - Visual Studio Marketplace

Interview question and answers

Image
OOPS, or Object-Oriented Programming System , is a programming paradigm that organizes software design around objects rather than functions or logic. An object is an instance of a class, which can contain data (attributes or properties) and methods (functions or behaviors) that operate on the data.OOP concepts help organize and structure code for better reusability, scalability, and maintenance. Here are the core OOP concepts in C#: 1. Encapsulation Encapsulation is the process of keeping data and methods that operate on that data within a single unit (i.e., a class) and restricting direct access to some of the object's components. This is achieved in C# by defining access modifiers like public , private , and protected . Example : csharp Copy code public class Car { private int speed; // Private field - accessible only within the class public int Speed // Public property with getter and setter { get { return speed; } set { speed = valu...