ReportController.cs 7.57 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using AIAHTML5.ADMIN.API.Models;
using System.Web.Http.Cors;
using System.Web.Cors;
using AIAHTML5.Server.Constants;
using log4net;
using System.Text;
using AIAHTML5.ADMIN.API.Entity;
namespace AIAHTML5.ADMIN.API.Controllers
{
    //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")]
    [RoutePrefix("Report")]
    public class ReportController : ApiController
    {
        AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities();
        [Route("GetUsageReport")]
        [HttpGet]
        public IHttpActionResult GetUsageReport(string sFromDate, string sToDate, string sAccoutNumber, string sZip, int iState, int iCountry, int pageNo, int pageLength)
        {
            
            var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
            var lstUsageReport = dbContext.usp_GetUsageReport(sFromDate, sToDate, sAccoutNumber, sZip, iState, iCountry, pageNo, pageLength, spRecordCount).ToList();
            return Ok(new { UserUsage = lstUsageReport, RecordCount = spRecordCount.Value });
            //return Ok(lstUsageReport);
        }

        [Route("GetCustomerSummeryReport")]
        [HttpGet]
        public IHttpActionResult GetCustomerSummeryReport(string sAccoutNumber, string sLicenseeFullName, Nullable<decimal> iStartPrice, Nullable<decimal> iEndPrice, int iLicenseType, int iAccountType, string sZip, int iState, int iCountry, int pageNo, int pageLength)
        {
            var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
            var lstCustomerSummeryReport = dbContext.usp_GetCustomerSummary(sAccoutNumber, sLicenseeFullName, iStartPrice, iEndPrice, (byte)iLicenseType, (byte)iAccountType, sZip, iState, iCountry, pageNo, pageLength, spRecordCount).ToList();
            return Ok(new { CustomerSummery = lstCustomerSummeryReport, RecordCount = spRecordCount.Value });
            //return Ok(lstCustomerSummeryReport);
        }


        [Route("GetExpiringSubscriptionReport")]
        [HttpGet]
        public IHttpActionResult GetExpiringSubscriptionReport(string sFromDate, string sToDate, decimal iStartPrice, decimal iEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, int pageNo, int pageLength)
        {
            var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
            var lstExpiringSubscriptionReport = dbContext.usp_GetExpiringLicenses(sFromDate, sToDate, iStartPrice, iEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, pageNo, pageLength, spRecordCount).ToList();
            return Ok(new { ExpiringSubscription = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value });
            
        }

        [Route("GetSubscriptionReport")]
        [HttpGet]
        public IHttpActionResult GetSubscriptionReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, int pageNo, int pageLength)
        {
            var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
            var lstExpiringSubscriptionReport = dbContext.usp_GetSubscribedLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, pageNo, pageLength, spRecordCount).ToList();
            return Ok(new { Subscription = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value });
        }
        [Route("GetSubscriptionCancellationReport")]
        [HttpGet]
        public IHttpActionResult GetSubscriptionCancellationReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, int pageNo, int pageLength)
        {
            var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
            var lstExpiringSubscriptionReport = dbContext.usp_GetCancelledLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, pageNo, pageLength, spRecordCount).ToList();
            return Ok(new { SubscriptionCancel = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value });
        }

        [Route("GetNetAdSummaryReport")]
        [HttpGet]
        public IHttpActionResult GetNetAdSummaryReport(string sFromDate, string sToDate, decimal iStartPrice, decimal iEndPrice, int iLicenseTypeId, int pageNo, int pageLength)
        {
            try
            {
                var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
                var lstNetAdSummaryReport = dbContext.usp_GetNetAdSummaryReport(sFromDate, sToDate, iStartPrice, iEndPrice, (byte)iLicenseTypeId, pageNo, pageLength, spRecordCount).ToList();
                return Ok(new { NetAdSubscriptionList = lstNetAdSummaryReport, RecordCount = spRecordCount.Value });
            }
            catch (Exception ex)
            {
                return Ok(ex.Message.ToString());
            }
        }


        [Route("GetSiteLicenseUsageReport")]
        [HttpGet]
        public IHttpActionResult GetSiteLicenseUsageReport(string sFromDate, string sToDate, string sAccountNumber, int iEdition, int iloginTypeId, int pageNo, int pageLength)
        {
            try
            {
                var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
                var lstSiteLicenseUsageReport = dbContext.usp_GetSiteLicenseUsageReports(sFromDate, sToDate, sAccountNumber, (byte)iEdition, (byte)iloginTypeId, pageNo, pageLength, spRecordCount).ToList();
                return Ok(new { SiteLicenseUsageList = lstSiteLicenseUsageReport, RecordCount = spRecordCount.Value });
            }
            catch (Exception ex)
            {
                return Ok(ex.Message.ToString());
            }
        }

        [Route("GetDiscountReport")]
        [HttpGet]
        public IHttpActionResult GetDiscountReport(string sFromDate, string sToDate, int iDiscountCode, string sAccountNumber, int pageNo, int pageLength)
        {
            try
            {
                var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
                var lstDiscountReport = dbContext.usp_GetDiscountReport(sFromDate, sToDate, iDiscountCode, sAccountNumber, pageNo, pageLength, spRecordCount).ToList();
                return Ok(new { DiscountReportList = lstDiscountReport, RecordCount = spRecordCount.Value });
            }
            catch (Exception ex)
            {
                return Ok(ex.Message.ToString());
            }
        }


        [Route("GetImageExportReport")]
        [HttpGet]
        public IHttpActionResult GetImageExportReport(string sFromDate, string sToDate, string sAccountNumber, int pageNo, int pageLength)
        {
            try
            {
                if (sAccountNumber == null) sAccountNumber = string.Empty;
                var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0);
                var lstImageExportReport = dbContext.usp_GetExportedImageDetails(sFromDate, sToDate, sAccountNumber, pageNo, pageLength, spRecordCount).ToList();
                return Ok(new { ImageExportList = lstImageExportReport, RecordCount = spRecordCount.Value });
            }
            catch (Exception ex)
            {
                return Ok(ex.Message.ToString());
            }
        }
	}
}