//
        // GET: /Contract/AuthorContract/
        public ActionResult Index(string SeriesIds, int?ProductId = 0, int?Id = 0, int?LicenceId = 0, string SeriesCode = "", string For = "")
        {
            if (ProductId == 0 && LicenceId != 0)
            {
                int _LicenceId = LicenceId.GetValueOrDefault();
                ACS.Core.Domain.Product.ProductLicense mobj_ProductLicense = _ProductLicenseService.GetProductLicenseById(_LicenceId);

                ViewBag.ProductId = mobj_ProductLicense.productid;
            }
            else
            {
                ViewBag.ProductId = ProductId;
            }



            ViewBag.ContractIdId = Id;
            ViewBag.LicenceId    = LicenceId;
            ViewBag.SeriesIds    = SeriesIds;
            ViewBag.SeriesCode   = SeriesCode;

            if (For != "")
            {
                if (For.ToLower() == "update")
                {
                    ViewBag.Update = For.ToLower();
                }
                if (For.ToLower() == "seriesupdate")
                {
                    ViewBag.Update = For.ToLower();
                }
            }
            else
            {
                ViewBag.Update = "dashboard";
            }

            if (_workContext.CurrentUser == null || Session["UserId"] == null)
            {
                // return new HttpUnauthorizedResult();
                TempData["From"] = "S";
                return(RedirectToAction("Login", "Login", new { area = "" }));
            }
            else
            {
                ViewBag.Department = _workContext.CurrentUser.DepartmentM.DepartmentCode.ToLower();
                return(View(_workContext.CurrentUser));
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult getLicenseDetailsByLicenseId(ACS.Core.Domain.Product.ProductLicense ProductLicense)
        {
            ACS.Core.Domain.Product.ProductLicense _ProductLicense = _ProductLicenseService.GetProductLicenseById(ProductLicense);

            DateTime?ProductLicenseExpirydate   = null;
            DateTime?ProductLicenseContractDate = null;
            // DateTime? ProductLicenseContractDate = _ProductLicense.ContractDate;



            var mstr_requestDate = _ProductLicenseUpdateDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == ProductLicense.Id).OrderByDescending(i => i.EntryDate).FirstOrDefault();

            if (mstr_requestDate != null)
            {
                ProductLicenseContractDate = mstr_requestDate.AgreementDate;
                ProductLicenseExpirydate   = mstr_requestDate.Expirydate;
            }



            // DateTime? ProductLicenseExpirydate = _ProductLicense.Expirydate;
            string format       = "dd/MM/yyyy";
            string ContractDate = ProductLicenseContractDate == null ? "" : Convert.ToDateTime(ProductLicenseContractDate).ToString(format);
            string ExpiryDate   = ProductLicenseExpirydate == null ? "" : Convert.ToDateTime(ProductLicenseExpirydate).ToString(format);
            var    LicenseData  = new
            {
                Id                 = _ProductLicense.Id,
                ProductId          = _ProductLicense.productid,
                AddendumId         = _ProductLicense.ProductLicenseAddendumLink.Where(a => a.Active == "Y").Select(a => a.AddendumId).FirstOrDefault(),
                ProductLicensecode = _ProductLicense.ProductLicensecode,
                Company            = _ProductLicense.LicensePublishing.CompanyName,
                ContactPerson      = _ProductLicense.ContactPerson,
                RequestDate        = _ProductLicense.Requestdate.Date.ToString("dd/MM/yyyy"),
                //ContractDate = _ProductLicense.ContractDate.Date.ToString("dd/MM/yyyy"),
                //ExpiryDate = _ProductLicense.Expirydate.Date.ToString("dd/MM/yyyy")

                Impression = _ProductLicense.printquantity == null
                            ? (_AddendumDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).OrderByDescending(a => a.EntryDate).Select(a => a.AddendumQuantity).FirstOrDefault())
                            : _ProductLicense.printquantity,
                ImpressionBalance = _ProductLicense.balanceqty == null
                                    ? ((_AddendumDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).OrderByDescending(a => a.EntryDate).Select(a => a.BalanceQuantity).FirstOrDefault()) == null
                                            ? (_ImpressionDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).OrderByDescending(a => a.EntryDate).Select(a => a.BalanceQty).FirstOrDefault())
                                            : (_AddendumDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).OrderByDescending(a => a.EntryDate).Select(a => a.BalanceQuantity).FirstOrDefault()))
                                    : _ProductLicense.balanceqty,

                //------------------------------------------------
                Licenseprintquantity      = _ProductLicense.printquantity,
                LicenseAddendumQuantity   = _AddendumDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).Select(a => a.AddendumQuantity).ToList(),
                ImpressionQuantityPrinted = _ImpressionDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).Select(a => a.QunatityPrinted).ToList(),

                BalanceQuantityCarryForward = _AddendumDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id).OrderByDescending(a => a.EntryDate).Select(a => a.BalanceQuantityCarryForward).FirstOrDefault(),
                LicenseAddendumQuantity1    = _AddendumDetails.Table.Where(a => a.Deactivate == "N" && a.LicenseId == _ProductLicense.Id && a.BalanceQuantityCarryForward == "N").OrderByDescending(a => a.EntryDate).Select(a => a.AddendumQuantity).FirstOrDefault(),
                ImpressionQuantityPrinted1  = _ImpressionDetails.Table.Where(a => a.Deactivate == "N" &&
                                                                             a.LicenseId == _ProductLicense.Id &&
                                                                             a.AddendumId == (_AddendumDetails.Table.Where(b => b.Deactivate == "N" && b.LicenseId == _ProductLicense.Id && b.BalanceQuantityCarryForward == "N").OrderByDescending(b => b.EntryDate).Select(b => b.Id).FirstOrDefault()))
                                              .Select(a => a.QunatityPrinted).ToList(),
                //------------------------------------------------

                ContractDate      = ContractDate,
                ExpiryDate        = ExpiryDate,
                printquantitytype = _ProductLicense.printquantitytype //Unrestricted or Number
            };

            return(Json(LicenseData));
        }