Saturday, March 7, 2015

RESTFUL service using WCF


Delete the default two files: that is IService, Service1.


Add-> New Item.





Add New Item and select Class




Employee.cs

[DataContract]
    public class Employee
    {
        [DataMember]
        public int UserId { get; set; }
        [DataMember]
        public string FirstName { get; set; }
        [DataMember]
        public string LastName { get; set; }
        [DataMember]
        public int Salary { get; set; }
    }
    public partial class EmployeeData
    {
        private static readonly EmployeeData _instance = new EmployeeData();
        private EmployeeData() { }
        public static EmployeeData Instance
        {
            get
            {
                return _instance;
            }
        }

        public List<Employee> EmployeeList
        {
            get
            {
                return employee;
            }
        }
            private List<Employee> employee = new List<Employee>() 
            { 
                 new Employee() { UserId = 1, FirstName = "Product 1", LastName = "Category ", Salary=10}, 
                new Employee() { UserId = 1, FirstName = "Product 1", LastName = "Category ", Salary=10}, 
                new Employee() { UserId = 1, FirstName = "Product 1", LastName = "Category ", Salary=10}
            };

        }




Iservice.cs




Service1.cs



Global.asax.


web.config.





Output:




No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...