<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using Cats.Areas.EarlyWarning.Models;
using Cats.Services.EarlyWarning;
using Cats.Models;
using System.Web.Mvc;
using Microsoft.Office.Interop.Word;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;


namespace Cats.Areas.EarlyWarning.Controllers
{
    public class GiftCertificateController : Controller
    {
        private readonly IGiftCertificateService _giftCertificateService;
        private readonly IGiftCertificateDetailService _giftCertificateDetailService;

        public GiftCertificateController(IGiftCertificateService giftCertificateService, IGiftCertificateDetailService giftCertificateDetailService)
        {
            _giftCertificateService = giftCertificateService;
            _giftCertificateDetailService = giftCertificateDetailService;
        }

        public ActionResult Index()
        {

            return View();
        }

        public JsonResult GetListOfCertificate([DataSourceRequest] DataSourceRequest request)
        {
            var giftCertList = _giftCertificateDetailService.GetAllGiftCertificateDetail();
             
            var result = giftCertList.ToList().Select(item => new GiftCertificateViewModel

                                                                  {
                                                                      CommodityName = item.Commodity.Name,
                                                                      GiftDate = item.GiftCertificate.GiftDate,
                                                                      Donor = item.GiftCertificate.Donor.Name,
                                                                      Program = item.GiftCertificate.Program.Name,
                                                                      ReferenceNo = item.GiftCertificate.ReferenceNo,
                                                                      GiftCertificateID = item.GiftCertificateID,
                                                                      SINumber = item.GiftCertificate.SINumber,
                                                                      PortName = item.GiftCertificate.PortName
                                                                  }).ToList();

            return Json(result.ToDataSourceResult(request, ModelState));
        }

        public ActionResult GenerateTemplate(string RefNo)
        {
            if (RefNo.Trim() == "")
                return RedirectToAction("Index");
            //OBJECT OF MISSING "NULL VALUE"
            string path = HttpContext.ApplicationInstance.Server.MapPath("~/Templates/gift_Certificate.dotx");
            if (path != null) Response.Write(path);
            Object oMissing = System.Reflection.Missing.Value;

            Object oTemplatePath = path ;

            List<GiftCertificateDetail> giftCert = GetGiftCertificate(RefNo);//"L1344/SF148/2011");

            if (giftCert.Count < 1)
                return RedirectToAction("Index");

            Application wordApp = new Application();
            Document wordDoc = new Document();
<commit_msg>excluded response write fo path<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using Cats.Areas.EarlyWarning.Models;
using Cats.Services.EarlyWarning;
using Cats.Models;
using System.Web.Mvc;
using Microsoft.Office.Interop.Word;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;


namespace Cats.Areas.EarlyWarning.Controllers
{
    public class GiftCertificateController : Controller
    {
        private readonly IGiftCertificateService _giftCertificateService;
        private readonly IGiftCertificateDetailService _giftCertificateDetailService;

        public GiftCertificateController(IGiftCertificateService giftCertificateService, IGiftCertificateDetailService giftCertificateDetailService)
        {
            _giftCertificateService = giftCertificateService;
            _giftCertificateDetailService = giftCertificateDetailService;
        }

        public ActionResult Index()
        {

            return View();
        }

        public JsonResult GetListOfCertificate([DataSourceRequest] DataSourceRequest request)
        {
            var giftCertList = _giftCertificateDetailService.GetAllGiftCertificateDetail();
             
            var result = giftCertList.ToList().Select(item => new GiftCertificateViewModel

                                                                  {
                                                                      CommodityName = item.Commodity.Name,
                                                                      GiftDate = item.GiftCertificate.GiftDate,
                                                                      Donor = item.GiftCertificate.Donor.Name,
                                                                      Program = item.GiftCertificate.Program.Name,
                                                                      ReferenceNo = item.GiftCertificate.ReferenceNo,
                                                                      GiftCertificateID = item.GiftCertificateID,
                                                                      SINumber = item.GiftCertificate.SINumber,
                                                                      PortName = item.GiftCertificate.PortName
                                                                  }).ToList();

            return Json(result.ToDataSourceResult(request, ModelState));
        }

        public ActionResult GenerateTemplate(string RefNo)
        {
            if (RefNo.Trim() == "")
                return RedirectToAction("Index");
            //OBJECT OF MISSING "NULL VALUE"
            string path = HttpContext.ApplicationInstance.Server.MapPath("~/Templates/gift_Certificate.dotx");
           
            Object oMissing = System.Reflection.Missing.Value;

            Object oTemplatePath = path ;

            List<GiftCertificateDetail> giftCert = GetGiftCertificate(RefNo);//"L1344/SF148/2011");

            if (giftCert.Count < 1)
                return RedirectToAction("Index");

            Application wordApp = new Application();
            Document wordDoc = new Document();

{'fraction_non_alphanumeric': 0.06277884002549394, 'fraction_numerical': 0.0038240917782026767, 'mean_word_length': 1.464468001570475, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4440517', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1221, 'n_words': 246}