Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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...

C#
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;

                        Getuserresponse.UserListAdd(userbusiness);
                    }
                    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
Updated 13-Sep-12 21:44pm
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900