Saturday, 23 April 2016

WEB API - GET(Without pass Value)

1. Controller(WebApiClass)

using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.Interfaces;
using LaySous.CineTot.ServiceAPI.Models;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace LaySous.CineTot.ServiceAPI.Controllers
{
    public class PaymentController : ApiController
    {
        static readonly IPayment oPayment = new MPayment();
        [HttpGet]
        public CPaymentList ShowPaymentList()
        {
            return oPayment.PaymentList();
        }
   }
}


2.InterFace(Interfaeclass)

using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LaySous.CineTot.ServiceAPI.Interfaces
{
    public interface IPayment
    {      
    CPaymentList PaymentList();   
    }
}


3. CPaymentList



using LaySous.CineTot.ServiceAPI.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LaySous.CineTot.ServiceAPI.POCO
{
    public class CPaymentList
    {
        public List<Payments> PaymentList;
        public CServerMessage ServerMsg;
    }
}



4.Payments
namespace LaySous.CineTot.ServiceAPI.Entities
{
    using System;
    using System.Collections.Generic;
   
    public partial class Payments
    {
        public long PaymentSK { get; set; }
        public long RegistrationSK { get; set; }
        public string RevenueSource { get; set; }
        public decimal AmountPaid { get; set; }
        public string SchemeCode { get; set; }
        public string PaymentMode { get; set; }
        public string TransactionRefCode { get; set; }
        public System.DateTime DateCreated { get; set; }
    }
}


5.MPayment
using LaySous.CineTot.ServiceAPI.Entities;
using LaySous.CineTot.ServiceAPI.Interfaces;
using LaySous.CineTot.ServiceAPI.POCO;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;

namespace LaySous.CineTot.ServiceAPI.Models
{
    public class MPayment : IPayment
    {
        FytotCtx oDataContext = new FytotCtx();
   
 public CPaymentList PaymentList()
        {
            CPaymentList oPaymentList = null;
            CServerMessage oServerMessage = null;

            try
            {
                oServerMessage = new CServerMessage();
                oServerMessage.Msg = CCommon.EnumMessages.FAILED.ToString();

                oPaymentList = new CPaymentList();
                oPaymentList.PaymentList = oDataContext.Payments.ToList();

                oServerMessage.Msg = CCommon.EnumMessages.SUCCESS.ToString();
            }
            catch (Exception oEx)
            {
                oServerMessage.Msg = CCommon.EnumMessages.EXCEPTION.ToString();
                oServerMessage.ExMsg = oEx.InnerException.ToString();
            }
            oPaymentList.ServerMsg = oServerMessage;

            return oPaymentList;
        }
     }
}







No comments: