Click here to Skip to main content
15,892,927 members
Articles / Programming Languages / C#

Using WCF Service with Silverlight

Rate me:
Please Sign up or sign in to vote.
4.81/5 (15 votes)
30 Sep 2011CPOL11 min read 95.6K   4.6K   28  
This article shows how to use WCF service with Silverlight
using System;
using System.ServiceModel.Activation;
using MoneyTracking.BLL;
using MoneyTracking.Common;

namespace MoneyTracking.Service
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MoneyService : IMoneyService
    {
        public ServiceResponse AddExpense(Expense expense)
        {
            var response = new ServiceResponse();
            using (var manager = new ExpenseManager())
            {
                try
                {
                    response.Result = manager.AddExpense(expense);
                    response.IsSuccess = true;
                }
                catch (Exception exception)
                {
                    response.ServiceException = exception;
                    response.IsSuccess = false;
                    response.ErrorMessage = "Unable to add Expense";
                }
            }
            return response;
        }

        public ServiceResponse UpdateExpense(Expense expense)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse DeleteExpense(Expense expense)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse GetExpenseByID(int expenseId)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse AddCategory(Category category)
        {
            var response = new ServiceResponse();
            response.IsSuccess = true;
            return response;
        }

        public ServiceResponse UpdateCategory(Category category)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse DeleteCategory(Category category)
        {
            var response = new ServiceResponse();
            return response;
        }

        public ServiceResponse GetCategoryByID(int categoryId)
        {
            var response = new ServiceResponse();
            return response;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer Riteq
Australia Australia
About Md. Masudur Rahman

Masudur currently works at Riteq as a software developer. Masudur Lives in Sydney, Australia.

Awards

26 May 2009: Monthly competition: Best ASP.NET article of April 2009

24 Mar 2009: Monthly competition: Best ASP.NET article of February 2009

Masudur Blog

Masudur put down his interesting learning experiences in his blog at http://munnaondotnet.blogspot.com/.

Comments and Discussions