コード例 #1
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));
        }
コード例 #2
0
        public IHttpActionResult InsertImpressionEntry(ImpressionDetails ImpressionDetails)
        {
            try
            {
                ImpressionDetails mobj_ImpressionDetails = new ImpressionDetails();
                if (ImpressionDetails.AddendumId > 0)
                {
                    AddendumDetails _AddendumDetails = new AddendumDetails();
                    _AddendumDetails.Id = ImpressionDetails.AddendumId.GetValueOrDefault();
                    AddendumDetails mobj_AddendumDetails = _AddendumServices.GetAddendumDetailsById(_AddendumDetails);
                    mobj_AddendumDetails.NoOfImpressions = mobj_AddendumDetails.NoOfImpressions - 1;
                    if (mobj_AddendumDetails.NoOfImpressions < 0)
                    {
                        return(Json("No. of impression are finished"));
                    }
                    mobj_AddendumDetails.BalanceQuantity = ImpressionDetails.BalanceQty - ImpressionDetails.QunatityPrinted;
                    if (mobj_AddendumDetails.BalanceQuantity < 0)
                    {
                        return(Json("No. of print are exceed"));
                    }
                    _AddendumServices.UpdateAddendumDetails(mobj_AddendumDetails);


                    ACS.Core.Domain.Product.ProductLicense _ProductLicense = new ACS.Core.Domain.Product.ProductLicense();
                    _ProductLicense.Id = ImpressionDetails.LicenseId.GetValueOrDefault();
                    ACS.Core.Domain.Product.ProductLicense mobj_ProductLicense = _ProductLicenseService.GetProductLicenseById(_ProductLicense);
                    mobj_ProductLicense.balanceqty = ImpressionDetails.BalanceQty - ImpressionDetails.QunatityPrinted;
                    _ProductLicenseService.UpdateProductLicense(mobj_ProductLicense);
                }
                else if (ImpressionDetails.LicenseId > 0)
                {
                    ACS.Core.Domain.Product.ProductLicense _ProductLicense = new ACS.Core.Domain.Product.ProductLicense();
                    _ProductLicense.Id = ImpressionDetails.LicenseId.GetValueOrDefault();
                    ACS.Core.Domain.Product.ProductLicense mobj_ProductLicense = _ProductLicenseService.GetProductLicenseById(_ProductLicense);
                    mobj_ProductLicense.noofimpressions = mobj_ProductLicense.noofimpressions - 1;
                    if (mobj_ProductLicense.noofimpressions < 0)
                    {
                        return(Json("No. of impression are finished"));
                    }
                    mobj_ProductLicense.balanceqty = ImpressionDetails.BalanceQty - ImpressionDetails.QunatityPrinted;
                    if (mobj_ProductLicense.balanceqty < 0)
                    {
                        return(Json("No. of print are exceed"));
                    }
                    _ProductLicenseService.UpdateProductLicense(mobj_ProductLicense);
                }
                mobj_ImpressionDetails.ProductId       = ImpressionDetails.ProductId;
                mobj_ImpressionDetails.LicenseId       = ImpressionDetails.LicenseId;
                mobj_ImpressionDetails.AddendumId      = ImpressionDetails.AddendumId;
                mobj_ImpressionDetails.ContractId      = ImpressionDetails.ContractId;
                mobj_ImpressionDetails.ImpressionNo    = ImpressionDetails.ImpressionNo;
                mobj_ImpressionDetails.ImpressionDate  = ImpressionDetails.ImpressionDate;
                mobj_ImpressionDetails.QunatityPrinted = ImpressionDetails.QunatityPrinted;
                mobj_ImpressionDetails.BalanceQty      = ImpressionDetails.BalanceQty - ImpressionDetails.QunatityPrinted < 0 ? null : ImpressionDetails.BalanceQty - ImpressionDetails.QunatityPrinted;
                mobj_ImpressionDetails.Deactivate      = "N";
                mobj_ImpressionDetails.EnteredBy       = ImpressionDetails.EnteredBy;
                mobj_ImpressionDetails.EntryDate       = DateTime.Now;
                mobj_ImpressionDetails.ModifiedBy      = null;
                mobj_ImpressionDetails.ModifiedDate    = null;
                mobj_ImpressionDetails.DeactivateBy    = null;
                mobj_ImpressionDetails.DeactivateDate  = null;
                _AddendumServices.ImsertImpressionDetails(mobj_ImpressionDetails);

                return(Json("OK"));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }