Showing posts with label sunitkanyan. Show all posts
Showing posts with label sunitkanyan. Show all posts

Saturday, May 28, 2016

Building WebAPI Using the Sales force Toolkit for .NET- PART 2 (Interaction with Sales force and ASP.NET WebAPI)

CRUD Operation in sales force's contact through ASP.NET WebAPI using sales force api.

if your client has apps on sales force cloud then something you may require deal with an asp.net /mobile application to interact with their sales force cloud.


This article will show you “How to perform CRUD with sales force api in asp.net”


Let's describe first the step involved:-
  • ·         Create a web api project.
  • ·         Add sales force nuget package.
  • ·         Add new api controller.
  • ·         Start developing get/add/edit/delete operation.
o   Get Operation: get all the contacts
o   Get a contact based on email id.
o   Add new contact.
o   Update contact.
o   Delete contact.


Create a web api project. >> Open visual studio 2010/2012/2013. And add empty solution. Thereafter add a web api project to it


Add sales force nuget package. >> DeveloperForce.Force





Add new API controller. >>




 Start developing get/add/edit/delete operation. >> Trying CRUD for contacts ,view your sales force cloud contact tab first as we are going to perform operations for same.

 Navigate to [Contacts]




Get Operation: get all the contacts. >>

Code:-

Result:-

Let us map result  to class object
Code:-

Result:-

Get contact based on email id. >>


Code:-
Result:-


Add new contact. >>

Code:-
Result:-

View New contact in sales force



Update contact detail. >> updating last name for contact in this example

Code:-

Result:-
View update last name in sales force


Delete contact. >>

Code:-


Result:-

Check in sales force                                                                                                                                                                                                  

compeleted crud operations for contacts similary can use same with little modification for leads opportunities, cutom reports etc..

-
Sunit
@SunitKanyan.in

How to perform CRUD with sales force api in asp.net
t

Building WebAPI Using the Sales force Toolkit for .NET- PART 1 (Interaction with Sales force and ASP.NET WebAPI)

Building WebAPI Using the Sales force Toolkit for .NET- PART I


This article is all about the setting up force.com account so that can interact thought  salesforce’s api in outside applications.


 Part II of this article will perform the CRUD operation by asp.net web api  for contacts.





The Following are the steps:-

  • ·        Signup for sales force developer account.
  • ·         Sign-in.
  • ·         Update your profile.
  • ·         Set/reset security password.
  • ·         Create a connected app.
  • ·         Get consumer key and consumer secret


Signup for sales force developer account:- Register on force.com and get a free 30 days account.
Open force.com and click for “Free trial” and follow all steps


 Sign-in:- open force.com and click login. Provide your user credentials




 Home screen



Update profile:- Navigate to [Your Name] > My Settings 
Set/Reset Security token:- Security token is required along with user password while interacting with api.
Navigate to [Your Name] > My Settings > Personal > Reset My Security Token


Create a connected app:-
Navigate to [Setup] > Apps > Connected app and click for new connected app. Fill the required detail to get key/secret. 


 click add for new connected app and fill all required details. It will accept only secure callback url.



Newly added app                                                                                                                                

Get consumer key /secret:-
Navigate to [Setup] > Apps > Connected app >Your connected app (say MyFirstSalesForceApp) and find key and secret, click on reveal to see consumer secret.




Now got salesforce ac username, password, security token, consumer key and consumer secret so can go for development of ASP.NET Web /api.


-
Sunit



Sunday, March 13, 2016

Comparison Sql Server and MongoDB for a database developer

Comparison Sql Server and MongoDB for a database developer


This article is all about the comparison between SQL Server(Relational database) to MongoDB(No-Sql database).

This morning just visited mongodb.com found mongo announced mongo 3.2. After going through their master manual for mongo 3.2 which is published on dated 11 March 2016, Friday. I just compared stuff which will help you to understand mongoDB operation quickly. MongoDB is not difficult for a relation database developer.


The following tables presents the various SQL terminology and concepts and the corresponding MongoDB terminology and concepts.

Terms Comparison

SQL Terms
Mongo Terms
Brief.
Database
Database
Organized collection of information
Table
Collection
Representation of row columns
Row
Document

Columns
Fields

Index
Index
Created to speed up the execution
Table joins
Embedded document & linking
Interlinked information
Primary key
Primary key
Quickly identify a record set/query result
Sql Terms, functions
WHERE
GROUP BY
HAVING
SELECT
ORDER BY
LIMIT
SUM()
COUNT()
join
Aggregation operators
$match
$group
$match
$project
$sort
$limit
$sum
$sum
$lookup
Matching ,grouping ,choosing, aggregate information to provide require result set/query result





















Schema Comparison

SQL Schema
Mongo Schema
Brief.

CREATE TABLE table1(
  id int not null Identity(1,1) Primary key,
  Name varchar(50),
  Shift char(1),
  Experience int
)

db.createCollection("table1")

db.table1.insert( {
Name: "Sunit Kanyan",
Shift: “G”
Experience: 5
} )



db.createCollection will create empty collection. Insert implicity create the collection.
The primary key _id will automated added in mongo.

Alter Table table1 add join_date DATETIME


db.table1.update(
 { }
{ $set: { join_date: new Date() } {  multi: true }
 )


Collection does not enforce structure of documents so there is no structure alteration at collection level. Update can add new fields in existing documents.

Alter Table table1 DROP COLUMN join_date


db.table1.update(
 { }
{ $unset: { join_date: “”  }
{  multi: true }
 )


Collection does not enforce structure of documents.
Update can remove a field by unset operator.

CREATE INDEX idx_table1_experience
ON table1(Experience)


db.table1.createIndex(
{ Experience: 1 } )


DROP Table table1

db.table1.drop()

















Insert Statement Comparison

SQL Insert Statements
Mongo Insert Statements
Brief.
Single Row Insert:-

INSERT INTO table1
 (Name
 ,Shift
 ,Experience)
VALUES 
('SunitKanyan'           ,'G'
,5)


INSERT INTO table1
VALUES       
('Sunit Kanyan'           ,'G'
,5)





db.table1.insert(
{ Name: “SunitKanyan”,
 Shift: “G”, Experience: 5 }
)






db.table1.insertOne(
{ Name: “Sunit Kanyan”,
 Shift: “G”, Experience: 5 }
)
 

Inserting document/record
Multiple Row Insert:-

INSERT INTO table1
 (Name
 ,Shift
 ,Experience)
VALUES 
('Sunit Kanyan'           ,'G'
,5),
('Sumit Ror'           ,'G'
,4),
('Sunit Ror'           ,'G'
,6),






db.table1.insertMany([
{ Name: “Sunit Kanyan”,
 Shift: “G”, Experience: 5 },
{ Name: “Sumit Ror”,
 Shift: “G”, Experience: 4 },
{ Name: “Sunit Ror”,
 Shift: “G”, Experience: 6 }
])


Inserting documents/records


















Update Statement Comparison

SQL Update Statements
Mongo Update Statements
Brief.
Single Row Update:-

Update table1
Set
Shift='E'          
Where           Experience =4



db.users.Update(
 { Experience: { $eq: 4} },
{ $set: { Shift: “E”,  }}
)


db.users.UpdateOne(
 { Experience: { $gt: 4} },
{ $set: { Shift: “E”,  }}
)

 

updating document/record
Multiple Row Update:-

Update table1
Set
Shift='E'          
Where           Experience > 4



db.users.UpdateMany(
 { Experience: { $gt: 4} },
{ $set: { Shift: “E”,  }}
)




Updating  documents/records











Select/Querying Statement Comparison

SQL Querying  Statements
Mongo Querying  Statements
Brief.
SELECT * FROM table1

db.table1.find()
Retrieve all record
SELECT id,Name,Shift,Experience FROM table1

db.table1.find(
{ },
{ Name:1, Shift:1, Experience:1)
Specified fields/columns
SELECT Name,Shift,Experience FROM table1

db.table1.find(
{ },
{  Name: 1, Shift: 1, Experience: 1, _id: 0 })
Specified fields/columns
SELECT * FROM table1
WHERE  Shift = 'E'          

db.table1.find(
{  Shift:  "E" })
Where clause
SELECT Name,Experience FROM table1
WHERE  Shift = 'E'          

db.table1.find(
{  Shift:  "E" },
{  Name: 1, Experience: 1 })
Where clause
SELECT *  FROM table1
WHERE  Shift = 'E'          

db.table1.find(
{  Shift:  {  $qe: "E" } } )
equal
SELECT *  FROM table1
WHERE  Shift != 'E'  
And   Experience = 5

db.table1.find(
{  Shift:  {  $ne: "E" } ,  Experience: 5} )
Not equal
SELECT *  FROM table1
WHERE  Shift = 'E'  
And   Experience = 5

db.table1.find(
{  Shift:  {  $eq: "E" } ,  Experience: 5} )
And  condition
SELECT *  FROM table1
WHERE  Shift = 'E'  
OR  Experience = 5

db.table1.find(
{  $or:  [Shift:  {  $qe: "E" } ,  
Experience: 5}
]  }
  )
Or condition
SELECT *  FROM table1
WHERE Experience > 4

db.table1.find(
Experience: { $gt: 4}} )
Greater than
SELECT *  FROM table1
WHERE Experience < 4

db.table1.find(
Experience: { $lt: 4}} )
Less than
SELECT *  FROM table1
WHERE Experience > 4
And   Experience <= 10

db.table1.find(
Experience: { $gt: 4, $lte: 10 } } )
And less/greater than
SELECT *  FROM table1
WHERE Name LIKE '%Sunit%'

db.table1.find(
Name: /Sunit/} )
Like
SELECT *  FROM table1
WHERE Experience in (3,4,5,6)
db. table1.find(  { Experience:  { $in:  [ 3,4,5,6 ] } } )
In
SELECT TOP 1 *  FROM table1

Db.table1.findOne()
Top
SELECT *  FROM table1 Order by Name

Db.table1.find().sort( { Name: 1})
Sort
SELECT DISTINCT Name FROM table1

db.table1.distinct(: "Name")
Distinct


























Delete Statement Comparison

SQL Delete  Statements
Mongo Delete  Statements
Brief
Delete FROM table1

db.table1.remove( { } )
All delete
Delete FROM table1
WHERE Experience = 4
db.table1.remove( { Experience: 4 } )
Conditional remove
Delete TOP (1) from table1  WHERE Experience = 4
db.table1.remove( { Experience: 4 } , true)
Top one delete











--
Sunit