Click here to Skip to main content
13,190,405 members (53,245 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have created a normal WCF service to retrieve the data from database .In this I am using 3 tier architecture (Business layer,Common Layer,Logic Layer) to post and get the data and my sample code is like this...

public static GetUserResponse Get(GetUserRequest Getuserrequest)
           GetUserResponse Getuserresponse = new GetUserResponse();
            Getuserresponse.UserList = new List<domainmodel.user>(); 
          Getuserresponse.UserBusinessList = new List<domainmodel.user>();                             
 using (ModelEntities ModelEntities = new ModelEntities())
                if (Getuserrequest.GetAction == "GetUserBusiness")
                   var UserBusiness = ModelEntities.UserBusinessSelect(Getuserrequest.UserId);
                    foreach (var B in UserBusiness)
                        DomainModel.UserBusiness userbusiness = new DomainModel.UserBusiness();
                        userbusiness.BusinessId = B.BusinessId;
                        userbusiness.Image = B.Image;
                        userbusiness.Link = B.Link;
                        userbusiness.ProviderId =(Guid) B.ProviderId;
                        userbusiness.Employee = new DomainModel.Employee();
                        userbusiness.Employee.Name = B.Name;
                    return Getuserresponse;
                if (Getuserrequest.GetAction == "GetUserNoteListByNoteId")
                    var UserNotes =ModelEntities.UserNotesSelectByNoteId(Getuserrequest.NoteId);
                    foreach (var N in UserNotes)
                        DomainModel.UserNotes usernotes = new UserNotes();
                        usernotes.Title = N.Title;
                        usernotes.Notes = N.Notes;
                        usernotes.UserId = N.UserId;
                        usernotes.Attachment = N.Attachment;
                        usernotes.AttachmentName = N.AttachmentName;
                        usernotes.AttachmentType = N.AttachmentType;
                        usernotes.ToEmail = N.ToEmail;
                        Getuserresponse.UserBusinessList .Add(usernotes);

Now I want to create RESt service for the same WCF service .I have gone through Google and came to know passing parameters in UriTemplate we can retrieve the data .My Question is instead of passing each parametre seperately in UriTemplate and get the details can I POST a request to an object and get the details?

In the above code GetUserRequest is the class and I am creating object to that class.And what ever the details I pass it goes in that method and checks for the corresponding stored procedure and get the details.But in the case of REST services I have to create two methods with two different UriTemplates which is difficult when we want to get details based on various parameters.

So I need a solution to convert the above code int REST services and also Posting Request to an object instead of creating UriTemplates seperately ......

Thanks in advance...
Posted 13-Sep-12 21:40pm
Updated 13-Sep-12 21:44pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171016.2 | Last Updated 14 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100