Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCF REST
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;
 
                        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 13-Sep-12 22:40pm
cutie1297
Edited 13-Sep-12 22:44pm
v2

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

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 14 Sep 2012
Copyright © CodeProject, 1999-2014
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