Wednesday, November 29, 2017

Controller.cs inside WebApi

namespace CSSI.VUE.Web.API.Controllers
{
public class ProducerEligibiltyController : ApiController
{

 

[CSSIScope("GET_PRODUCER_ELIGIBILITY")]
[HttpGet]
public ResponseMessageResult Get(
string ApplicationSignedDate,
string CarrierCode,
string LOB,
string SitusState,
string RequestType,
string AgentCode = null,
string WritingNumber = null,
string SolicitationState = null)
{
AgentDemographicResponse obj = null;
AgentDemographicRequest req = new AgentDemographicRequest();
MetLifeEncryptDecryptAES encryption = new MetLifeEncryptDecryptAES();

req.RequestType = RequestType;
req.AgentCode = AgentCode;
req.ApplicationSignedDate = DateTime.ParseExact(ApplicationSignedDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
req.CarrierCode = CarrierCode;
req.LOB = LOB;
req.SitusState = SitusState;
req.SolicitationState = SolicitationState;
req.WritingNumber = WritingNumber;

ICommonExtService service = ProxyHelper.GetCommonServiceProxy();
if (service != null)
{
obj = service.ProducerEligibility(req);
if (obj.ErrorMessage == "" || string.IsNullOrEmpty(obj.ErrorMessage))
{
if (obj.IsAgency == "1")
{
if (!string.IsNullOrEmpty(obj.TaxID))
{
obj.TaxID = encryption.Encrypt(WebHelper.Encryption(obj.TaxID, false));
}
}
else
{
if (!string.IsNullOrEmpty(obj.SSN))
{
obj.SSN = encryption.Encrypt(WebHelper.Encryption(obj.SSN, false));
}
}
}
}

//XElement xeAgentDemographicResponse = EntityHelper.XmlSerializeEntity(obj);
//return xeAgentDemographicResponse.ToString();
//if (obj.AgentCode == null)
//{
// obj.AgentCode = "";
//}

return ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ObjectContent<AgentDemographicResponse>(obj,
new System.Net.Http.Formatting.XmlMediaTypeFormatter
{
UseXmlSerializer = true
})

});

}}
}

Web Service Project Structure :-

  1. Entity Project Class file–>DLL

Agent.cs  File:-

#region usings

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using CSSI.Common.Utilities;
using CSSI.VUE.Common.Entities;
using CSSI.VUE.Custom.Entities;
using System.Web.Mvc;
using CSSI.VUE.Entities;

No comments:

Post a Comment