Friday, 20 February 2015

What is MongoDB and How to install MongoDB and its Service

MongoDB


MongoDB is an open-source, document-oriented database designed for ease of development and scaling.

Below given table shows the relationship of RDBMS terminology with MongoDB
RDBMS
MongoDB
Database
Database
Table
Collection
Tuple/Row
Document
column
Field
Table Join
Embedded Documents
Primary Key
Primary Key (Default key _id provided by mongodb itself)

Install MongoDB On Windows

To install the MongoDB on windows, first doownload the latest release of MongoDB from http://www.mongodb.org/downloads  Make sure you get correct version of MongoDB depending upon your windows version.

Install MongoDB Service

After installation we need to run MongoDb service.

1. Open command prompt in administrator mode.
2. Go to path C:\Program Files\MongoDB 2.6 Standard\bin

3. Make 2 directories in C drive. Run the below commands.
  mkdir c:\data\db
  mkdir c:\data\log



4. Run the below command
  
   echo dbpath=c:\data\db>> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg" 






5. To run the service run below command. In this service name is "MongoDB 2.6 Standard"

   sc.exe create MongoDB binPath= 
"\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\"    
--service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" 
   DisplayName= "MongoDB 2.6 Standard" start= "auto"


you will get the message service created successfully.


6. After installation go to service.msc and you will see Mongo Db service in the list.










7. To start the service write below command.
  
  net start MongoDB



you will get above message service was started successfully.

8. To check the service is running go to run and write service.msc and see service is running as highlighted in below screenshot.




Enjoy Mongo Db and create your collection(table).

Thanks for reading this article.


Tuesday, 6 January 2015

Implement Swagger (Swashbuckle) - Web API Help Page


Web API Documentation using Swagger

Swagger is the best way to create proper documentation for your web API. Creating documentation for your Web API is a huge success.

Swagger is framework for describing you API.

Steps to Add Swashbuckle to ASP.NET Web API

1. Install the Nuget Package


Open NuGet Package Manager Console and install the below package:

Install-Package Swashbuckle


Or

Right click on the API Project and click Manage NuGet Package and search "SwashBuckle" as shown in below screenshot.

Once this package is installed it will install a bootstrapper (App_Start/SwaggerConfig.cs) file which initiates Swashbuckle on application.

2. Enable generating XML documentation


This is not a mandatory step however, it is quite useful when you are using complex model.

Right click on your API Project ---> Go to Properties --> Select Build
See the below screenshot.


Select the checkbox "XML" documentation file.



3. Configure Swashbuckle for using XML Comments


Go to App_Start and open Swagger.config. Use the code below and give the same path that you mentioned in Step 2. This setting is only for version 4.1.0. For above version like 5.0 no need to do below settings. As Bootstrapper is not available in new version.
public class SwaggerConfig
    {
        public static void Register()
        {
            Swashbuckle.Bootstrapper.Init(GlobalConfiguration.Configuration);          
            SwaggerSpecConfig.Customize(c =>
            {
                c.IncludeXmlComments(GetXmlCommentsPath());
            });
        }

        private static string GetXmlCommentsPath()
        {
            return Path.Combine(System.Web.HttpRuntime.AppDomainAppPath, "bin", "DentalServices.CarrierBestWay.Api.XML");
        }

    }

4. Annotating your API methods


Open your Controller Web API method and add Response Type. Again this is not mandatory to add Response Type but it is quite helpful to get your method information.

 [HttpPost]
        [ResponseType(typeof(Rule))]
        public IHttpActionResult Post(Rule model)

        {
          //your code
        }

5. Run the Swagger


 Run you Web API Project and write "Swagger" at the end of the URL.
like this http://localhost:64850/swagger.

The page will open like below screenshot which contains all you web API methods
with Response Type description. You can run you method directly from here like Chrome PostMan and Fiddler. It is very helpful.


In attached screenshot there are 2 methods, one for GET and one for POST. Click on GET method it will expand like below screenshot form where you can run you GET method directly from here. See Press the "try it out" button. It is giving the description that in GET method you will get Rule collection.




Same in case of POST method. you can test you POST method directly form this page.

That's all about the post, hope you like it.


How to get PowerBI Embed Token

 Here's a step-by-step guide to help you through the process. Step 1: Register Your App in Azure 1. Go to Azure Portal → App registratio...