Esempio n. 1
0
        //GetConsignmentTotals
        public UICInvoice GetConsignmentTotals(long consignment_id)
        {
            DataCacheObject dco = new DataCacheObject(DataCacheType.ACTIVITY, DataCacheRegions.INVOICES, "GETCONSIGNMENTTOTALS",
                                                      new object[] { consignment_id }, CachingExpirationTime.Hours_01);
            UICInvoice result = CacheRepository.Get(dco) as UICInvoice;

            if (result != null)
            {
                return(result);
            }
            int?totalamount = 0;

            result =
                (from p in
                 dataContext.spInvoice_View_ConsignorStatements(consignment_id, null, null, null, 0, 1, ref totalamount)
                 select new UICInvoice
            {
                AmountDue = p.ADue.GetValueOrDefault(0),
                AmountPaid = p.APaid.GetValueOrDefault(0),
                TotalCost = p.TotalCost.GetValueOrDefault(0)
            }).FirstOrDefault();
            if (result != null)
            {
                dco.Data = result;
                CacheRepository.Add(dco);
            }
            return(result);
        }
        //GetConsignorStatementsBySearch
        public object GetConsignorStatementsBySearch(string sidx, string sord, int page, int rows, long?invoice_id, long?auction_id, long?event_id, long?user_id)
        {
            int?totalrecords = 0;
            int pageindex    = (page > 0) ? page - 1 : 0;

            dataContext.CommandTimeout = 600000;
            var res = dataContext.spInvoice_View_ConsignorStatements(invoice_id, auction_id, event_id, user_id, pageindex, rows, ref totalrecords);

            if (totalrecords.GetValueOrDefault(0) == 0)
            {
                return new { total = 0, page = page, records = 0 }
            }
            ;
            return(new
            {
                total = (int)Math.Ceiling((float)totalrecords.GetValueOrDefault(0) / (float)rows),
                page = page,
                records = totalrecords.GetValueOrDefault(0),
                rows = (
                    from query in res
                    select new
                {
                    i = query.Consignment_ID,
                    cell = new string[] {
                        query.Consignment_ID.ToString(),
                        query.EventTitle,
                        query.FLName,
                        query.Pending.GetCurrency(false),
                        query.TotalCost.GetCurrency(false),
                        query.APaid.GetCurrency(false),
                        query.ADue.GetCurrency(false),
                        query.Owner_ID.GetValueOrDefault(0).ToString()
                    }
                }).ToArray()
            });
        }