Sunday, October 1, 2023

Create dot net core project through Dotnet CLI

 We are going to create following project structure through PowerShell script. where we are using purely dotnet cli commands


You can create new file and name as "createProject.ps1" and copy following script into that file. then open powershell window and execute "createProject.ps1" file.

Refer following script

Write-Host "About to Create the directory" -ForegroundColor Green

mkdir Reactivities

cd Reactivities

Write-Host "About to create the solution and projects" -ForegroundColor Green

dotnet new sln

dotnet new webapi -n API

dotnet new classlib -n Application

dotnet new classlib -n Domain

dotnet new classlib -n Persistence

Write-Host "Adding projects to the solution" -ForegroundColor Green

dotnet sln add API/API.csproj

dotnet sln add Application/Application.csproj

dotnet sln add Domain/Domain.csproj

dotnet sln add Persistence/Persistence.csproj

Write-Host "Adding project references" -ForegroundColor Green

cd API

dotnet add reference ../Application/Application.csproj

cd ../Application

dotnet add reference ../Domain/Domain.csproj

dotnet add reference ../Persistence/Persistence.csproj

cd ../Persistence

dotnet add reference ../Domain/Domain.csproj

cd ..

Write-Host "Executing dotnet restore" -ForegroundColor Green

dotnet restore

Write-Host "Finished!" -ForegroundColor Green


It will create folder structure as below 


If you open solution file in Visual studio, you can see project structure as below:



Thursday, August 24, 2023

timespan property for api request in c# example

 I have defined a model where starttime and endtime are timespan fields. In swagger, by default it takes input in ticks as you see in below code but i want data to be taken in "hh:mm:ss" format.

 {
      "availableToCallExternalId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "startTime": {
        "ticks": 0
      },
      "endTime": {
        "ticks": 0
      },
      "availableDays": "string"
    }

How can we fix this issue?

Solution is we need to tell swagger that for timespan datatype we need "hh:mm:ss" format data and we can provide sample data 

public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(Configuration);
            services.AddControllers()
                .AddFluentValidation(mvcConfig => mvcConfig.RegisterValidatorsFromAssemblyContaining<Startup>())
                .AddNewtonsoftJson(options =>
                {
                    options.SerializerSettings.Converters.Add(new StringEnumConverter());
                });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc(SwaggerConstants.Version, new OpenApiInfo
                {
                    Title = SwaggerConstants.Title,
                    Version = SwaggerConstants.Version,
                });

                c.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme
                {
                    Name = "Authorization",
                    Type = SecuritySchemeType.Http,
                    Scheme = "bearer",
                    BearerFormat = "JWT",
                    In = ParameterLocation.Header,
                    Description = "JWT Authorization header using the Bearer scheme.",
                });

                c.MapType<TimeSpan>(() => new OpenApiSchema
                {
                    Type = "string",
                    Example = new OpenApiString("00:00:00"),
                });

Tuesday, August 15, 2023

Transforming your life in a 360-degree manner

 It's great that you're motivated to make a positive change in your life! Transforming your life in a 360-degree manner is a significant undertaking, but it's definitely achievable with the right mindset and approach. Here's a step-by-step guide to help you get started:

  1. Set Clear Goals: Begin by defining specific goals you want to achieve in different areas of your life, such as health, fitness, career, relationships, and personal development. Make these goals realistic and actionable.

  2. Create a Vision: Envision the person you want to become and the life you want to lead. Visualizing your ideal future can serve as a powerful motivator.

  3. Develop a Plan: Break down your goals into smaller, manageable steps. Create a detailed plan for each goal, outlining the actions you need to take and the timeline you want to follow.

  4. Health and Fitness:

    • Consult a healthcare professional before making significant changes to your diet or exercise routine.
    • Focus on a balanced diet with plenty of fruits, vegetables, lean proteins, and whole grains.
    • Incorporate regular exercise into your routine, such as walking, jogging, swimming, or yoga.
    • Gradually increase physical activity to avoid burnout and injuries.
  5. Energy and Well-Being:

    • Prioritize quality sleep by establishing a consistent sleep schedule and creating a calming bedtime routine.
    • Practice stress management techniques, such as meditation, deep breathing, and mindfulness.
    • Stay hydrated and avoid excessive caffeine and sugar intake.
  6. Personal Development:

    • Set aside time for self-reflection and personal growth. Consider journaling or seeking therapy/counseling if needed.
    • Engage in learning new skills or hobbies that interest you.
    • Read self-improvement books or listen to motivational podcasts.
  7. Relationships:

    • Nurture your relationships with family and friends by spending quality time together.
    • Develop and maintain healthy communication habits.
    • Seek support from your loved ones as you embark on your transformation journey.
  8. Time Management:

    • Prioritize tasks and use time management techniques to make the most of your day.
    • Consider setting boundaries to ensure a healthy work-life balance.
  9. Positive Mindset:

    • Cultivate a positive attitude and practice gratitude daily.
    • Surround yourself with positive influences, whether it's through books, online communities, or social interactions.
  10. Resources:

    • Books: "Atomic Habits" by James Clear,
    • "The Power of Habit" by Charles Duhigg,
    • "Awaken the Giant Within" by Tony Robbins.
    • Online Courses: Websites like Coursera, Udemy offer a wide range of courses for personal and professional development.
    • Fitness and Nutrition Apps: Apps like MyFitnessPal, Nike Training Club, and Calm can help you track your progress and provide guidance.

Remember that transformation takes time and consistency. It's okay to start small and gradually build up. Be patient with yourself and celebrate your successes along the way. If you find it challenging to stay motivated or make progress, don't hesitate to seek guidance from a life coach, therapist, or support group. Your commitment and determination will be key to achieving the positive impact you're seeking.

Monday, July 24, 2023

How to become full stack developer

 Becoming a full-stack developer involves acquiring a broad range of skills in both front-end and back-end web development. Here's a step-by-step guide to help you on your journey to becoming a full-stack developer:



  1. Foundation in Web Technologies:

    • Start with the basics of HTML, CSS, and JavaScript, as they form the foundation of web development.
    • Learn about DOM manipulation, styling, and basic interactivity with JavaScript.

  2. Front-End Development:

    • Dive deeper into front-end development by learning popular frameworks like React, Angular, or Vue.js.
    • Understand how to build responsive and user-friendly interfaces.
    • Learn about version control systems like Git to manage your code effectively.

  3. Back-End Development:

    • Choose a server-side language to learn, such as .NET, Python, Ruby, JavaScript (Node.js), PHP, or Java.
    • Understand server-side concepts like handling HTTP requests, databases, and APIs.
    • Learn about databases, including SQL (e.g., MySQL, PostgreSQL) and NoSQL (e.g., MongoDB) options.

  4. Databases:

    • Gain knowledge of database design, data modeling, and querying languages like SQL.
    • Learn how to interact with databases from the back-end using your chosen server-side language.

  5. Full-Stack Frameworks:

    • Explore full-stack frameworks like Django (Python), Ruby on Rails (Ruby), or MEAN (MongoDB, Express.js, Angular, Node.js).
    • These frameworks provide tools and structures to build both front-end and back-end components efficiently.

  6. APIs and Microservices:

    • Learn how to build and consume APIs (Application Programming Interfaces) to communicate between front-end and back-end components.
    • Understand microservices architecture to build scalable and modular applications.

  7. Version Control:

    • Master Git and understand how to work collaboratively on projects, manage branches, and handle code merges.

  8. Deployment and Hosting:

    • Learn how to deploy your applications to web servers or cloud platforms like AWS, Heroku, or Azure.

  9. Testing and Debugging:

    • Learn about testing methodologies and tools to ensure the reliability and functionality of your code.
    • Practice debugging techniques to find and fix issues in your applications.

  10. Continuous Learning:

    • Web development is a rapidly evolving field, so stay up-to-date with the latest trends, frameworks, and best practices.
    • Follow blogs, attend webinars, and participate in online coding communities to keep learning.

  11. Build Projects:

    • Apply your knowledge by building real-world projects. Building projects will help reinforce your skills and create a portfolio to showcase your work to potential employers.

  12. Networking and Collaboration:

    • Engage with the developer community through meetups, conferences, and online forums.
    • Collaborate on open-source projects to gain practical experience and connect with other developers.

Remember, becoming a full-stack developer is a journey that takes time and dedication. Stay persistent, keep coding, and continuously expand your skillset, and you'll be on your way to becoming a successful full-stack developer.