Friday, 8 April 2016

Blog Moved to codeteddy.com



Hi Readers,

This blog has been moved to codeteddy.com and is no longer supported. You'll find all the recent and latest articles on codeteddy.com


codeteddy.com

Read more:


My other series of articles:· Learning WebAPIs in .Net· Learning OOP concepts with C#· Learning MVCFor more technical articles you can reach out to my personal blog CodeTeddy.




                                                                                  


Share/Bookmark

Wednesday, 2 March 2016

RESTful Day #7: Unit Testing and Integration Testing in WebAPI using NUnit and Moq framework (Part 1)

Source Code at GitHub

Introduction

We have been learning a lot in WebAPI. We covered almost all the techniques required to build a robust and a full stack REST service using ASP.NET WebAPI, from creating a service to making it a secure and ready-to-use boilerplate with enterprise level applications. In this article, we’ll learn on how to focus on test driven development and write unit tests for our service endpoints and business logic. I’ll use NUnit and Moq framework to write test cases for business logic layer and controller methods. I’ll cover less theory and focus more on practical implementations on how to use these frameworks to write unit tests. I have segregated the article into two parts. The first part focusses on testing business logic and class libraries created as BusinessServices in our code base. The second part will focus on testing a Web API. The purpose of segregation is simple; the scope of this article is very large and may turn up into a very large post which would be not easy to read in one go.

Roadmap

The following is the roadmap I have setup to learn WebAPI step by step:




Share/Bookmark

Monday, 12 October 2015

Vote for my article on code project for best Web Dev article of September 2015.

Vote for my article on code project for best Web Dev article of September 2015.


Hi Friends,

It gives me immense pleasure to share that my article (http://www.codeproject.com/Articles/1028416/RESTful-Day-sharp-Request-logging-and-Exception-ha) has been nominated in one of the category "Best Web Dev Article of September 2015" on codeproject.com


You can vote on this articles if it helped you by any means.


Share/Bookmark

Wednesday, 9 September 2015

RESTful Day #6: Request logging and Exception handling/logging in Web APIs using Action Filters, Exception Filters and NLog

Download Source Code from GitHub

Introduction

We have been learning a lot about WebAPI, its uses, implementations, and security aspects since last five articles of the series. This article of the series will explain how we can handle requests and log them for tracking and for the sake of debugging, how we can handle exceptions and log them. We’ll follow a centralized way of handling exceptions in WebAPI and write our custom classes to be mapped to the type of exception that we encounter and log the accordingly. I’ll use NLog to log requests and exceptions as well. We’ll leverage the capabilities of Exception Filters and Action Filters to centralize request logging and exception handling in WebAPI.

Roadmap

The following is the roadmap I have setup to learn WebAPI step by step,
I’ll purposely use Visual Studio 2010 and .NET Framework 4.0 because there are few implementations that are very hard to find in .NET Framework 4.0, but I’ll make it easy by showing how we can do it.

Request Logging

Since we are writing web services, we are exposing our end points. We must know where the requests are coming from and what requests are coming to our server. Logging could be very beneficial and helps us in a lot of ways like, debugging, tracing, monitoring and analytics.

We already have an existing design. If you open the solution, you’ll get to see the structure as mentioned below or one can also implement this approach in their existing solution as well.

Share/Bookmark

Tuesday, 7 July 2015

Diving into OOP (Day 8): Indexers in C# (A Practical Approach)

Introduction

In my last article of this series we learnt about properties in c#. This article of the series "Diving into OOP" will explain all about indexers in C#, its uses and practical implementation. We’ll follow the same way of learning i.e. less theory and more practical. I’ll try to explain the concept in-depth.

Indexers in C# (The definition)

Let’s take the definition from https://msdn.microsoft.com/en-us/library/6x16t2tx.aspx,
"Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters."

Roadmap

Let’s recall our road map,


Share/Bookmark

Diving into OOP (Day 7): Properties in C# (A Practical Approach)

Introduction:

My article of the series "Diving into OOP" will explain all about properties, its uses and indexers in C#. We’ll follow the same way of learning i.e. less theory and more practical. I’ll try to explain the concept in-depth.

Properties (The definition):

Let’s start with the definition taken from MSDN
"A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field. Properties can be used as if they are public data members, but they are actually special methods called accessors. This enables data to be accessed easily and still helps promote the safety and flexibility of methods."

Roadmap:

Let’s recall our road map,

Share/Bookmark

RESTful Day #5: Security in Web APIs-Basic Authentication and Token based custom Authorization in Web APIs using Action Filters

Introduction

Security has always been a major concern we talk about enterprise level applications, especially when we talk about exposing our business through services. I have already explained a lot on WebAPI in my earlier articles of the series. I explained, how do we create a WebAPI, how to resolve dependencies to make it a loosely coupled design, defining custom routes, making use of attribute routing. My article will explain how we can achieve security in a WebAPI. This article will explain how to make WebAPI secure using Basic Authentication and Token based authorization. I’ll also explain how we can leverage token based authorization and Basic authentication in WebAPI to maintain sessions in WebAPI. There is no standard way of achieving security in WebAPI. We can design our own security technique and structure which suits best to our application.

Roadmap

Following is the roadmap I have setup to learn WebAPI step by step,


Share/Bookmark

Friday, 12 June 2015

Vote for my article on codeproject for best Web Dev article of June 2015.

Vote for my article on code project for best Web Dev article of May 2015.


Hi Friends,

It gives me immense pleasure to share that my article (http://www.codeproject.com/Articles/997216/RESTful-Day-sharp-Resolve-dependency-of-dependenci) has been nominated in one of the category "Best Web Dev Article of June 2015" on codeproject.com


You can vote on this articles if it helped you by any means.


Share/Bookmark

Thursday, 11 June 2015

RESTful Day #4: Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs

Download Source Code

Introduction

We have already learnt a lot on WebAPI. I have already explained how to create WebAPI, connect it with database using Entity Framework, resolving dependencies using Unity Container as well as using MEF. In all our sample applications we were using default route that MVC provides us for CRUD operations. In this article I’ll explain how to write your own custom routes using Attribute Routing. We’ll deal with Action level routing as well as Controller level routing. I’ll explain this in detail with the help of a sample application. My new readers can use any Web API sample they have, else you can also use the sample applications we developed in my previous articles.

Share/Bookmark

Wednesday, 3 June 2015

RESTful Day #3: Resolve dependency of dependencies using Inversion of Control and dependency injection in ASP.NET Web APIs with Unity Container and Managed Extensibility Framework (MEF)

Download Source Code

Introduction

In my last two articles I explained how to create a RESTful service using ASP.NET Web API working with Entity Framework and resolving dependencies using Unity Container. In this article I’ll explain how to create a loosely coupled system with Unity Container and MEF(Managed Extensibility Framework) using Inversion of Control. I’ll not be explaining much theory but rather focus more on practical implementations. For the readers who are following this series, they can use their existing solution that they have created till time. For my new readers of this article, I have provided the download link for the previous source code and current source code as well.
For theory and understanding of DI and IOC you can follow the following links: Unity and Inversion of Control(IOC).

Roadmap



Share/Bookmark

Thursday, 21 May 2015

RESTful Day #2: Inversion of control using dependency injection in Web API's using Unity Container and Bootstrapper

Introduction

My article will explain how we can make our Web API service architecture loosely coupled and more flexible. We already learnt that how we can create a RESTful service using Asp.net Web API and Entity framework in my last article. If you remember we ended up in a solution with a design flaw, we’ll try to overcome that flaw by resolving the dependencies of dependent components. For those who have not followed my previous article, they can learn by having the sample project attached as a test application from my first article.




Share/Bookmark

Tuesday, 12 May 2015

RESTful Day #1: Enterprise Level Application Architecture with Web API’s using Entity Framework, Generic Repository Pattern and Unit of Work

Introduction

I have been practicing, reading a lot about RESTful services for past few days. To my surprise I could not find a complete series of practical implementations of ASP.NET Web API’s on the web. My effort in this series will be to focus on how we can develop basic enterprise level application architecture with Web API’s.


Share/Bookmark

Sunday, 14 September 2014

A Practical Approach: News

A Practical Approach: News: Vote for my article on code project for best c# article of August 2014. Hi Friends, It gives me immense pleasure to share that my artic...

Share/Bookmark

Thursday, 11 September 2014

Diving in OOP (Day 6): Understanding Enums in C# (A Practical Approach)

Introduction

My article of the series “Diving in OOP” will explain enum datatype in C#. We’ll learn by doing hands on lab and not only by theory. We’ll explore the power of enum and will cover almost every scenario in which we can use enum. We’ll follow a practical approach of learning to understand this concept. We may come across complex examples to understand the concept more deeply.


Share/Bookmark

Saturday, 12 July 2014

News: VOTE FOR MY ARTICLE ON CODE PROJECT.

News

It gives me immense pleasure to share that my article (http://www.codeproject.com/Articles/792326/Diving-into-OOP-Day-All-About-Csharp-Access-Modifi) has been nominated in one of the category " Best C# article of the month July 2014" on codeproject.com


You can vote on this articles if it helped you by any means.

Share/Bookmark