/// <summary>
        /// Return list of products from XML.
        /// </summary>
        /// <returns>List of products</returns>
        public List <TransactionInfo> RetrunListOfProducts(string filepath)
        {
            string basicPath = HttpContext.Current.Server.MapPath("~/FileData/");

            string                 csvDataPath = string.Concat(basicPath, filepath);
            List <TempCSVInfo>     tmpList     = new List <TempCSVInfo>();
            TempCSVInfo            addTemp;
            List <TransactionInfo> results = new List <TransactionInfo>();
            TransactionInfo        addObj;
            PaymentDetailInfo      addDetail;
            DataSet                l_set   = new DataSet();
            string                 csvData = System.IO.File.ReadAllText(csvDataPath);
            //Execute a loop over the rows.
            string distinctInvNo = string.Empty;
            string format        = "dd/MM/yyyy HH:mm:ss";

            foreach (string row in csvData.Split('\n'))
            {
                if (!string.IsNullOrEmpty(row))
                {
                    addTemp                 = new TempCSVInfo();
                    addTemp.Id              = row.Split(',')[0].Trim();
                    addTemp.Amount          = Convert.ToDecimal(row.Split(',')[1].Trim());
                    addTemp.CurrencyCode    = row.Split(',')[2].Trim();
                    addTemp.TransactionDate = DateTime.ParseExact(row.Split(',')[3].Trim(), format, CultureInfo.InvariantCulture);
                    addTemp.Status          = row.Split(',')[4].Trim();
                    tmpList.Add(addTemp);
                    distinctInvNo = row.Split(',')[0].Trim();
                }
            }
            var linq_distinct = (from tmp in tmpList
                                 select new { tmp.Id, tmp.Status }).Distinct();

            foreach (var item in linq_distinct)
            {
                addObj                   = new TransactionInfo();
                addObj.Id                = item.Id;
                addObj.Status            = item.Status;
                addObj.TransactionDate   = tmpList.Where(c => c.Id == item.Id).OrderByDescending(c => c.TransactionDate).FirstOrDefault().TransactionDate;
                addObj.PaymentDetailInfo = new List <PaymentDetailInfo>();
                foreach (var d_item in tmpList.Where(c => c.Id == item.Id))
                {
                    addDetail              = new PaymentDetailInfo();
                    addDetail.Amount       = d_item.Amount;
                    addDetail.CurrencyCode = d_item.CurrencyCode;
                    addObj.PaymentDetailInfo.Add(addDetail);
                }
                results.Add(addObj);
            }
            return(results);
        }
Exemple #2
0
        public List <TransactionInfo> RetrunListOfProducts(string filepath)
        {
            string xmlData = HttpContext.Current.Server.MapPath(filepath);
            List <TransactionInfo> results = new List <TransactionInfo>();
            TransactionInfo        addObj;
            PaymentDetailInfo      addDetail;
            DataSet l_set   = new DataSet();
            string  xmlPath = HttpContext.Current.Server.MapPath("~/FileData/");

            l_set.ReadXml(string.Concat(xmlPath, filepath));
            if (l_set != null)
            {
                DataTable l_tbl = new DataTable();
                DataTable d_tbl = new DataTable();
                l_tbl = l_set.Tables["Transaction"];
                d_tbl = l_set.Tables["PaymentDetails"];
                foreach (DataRow dr in l_tbl.Rows)
                {
                    addObj                 = new TransactionInfo();
                    addObj.Id              = dr["id"].ToString();
                    addObj.Status          = dr["Status"].ToString();
                    addObj.TransactionDate = Convert.ToDateTime(dr["TransactionDate"].ToString());
                    DataTable tblFiltered = d_tbl.AsEnumerable()
                                            .Where(row => row.Field <Int32>("Transaction_Id") == Convert.ToInt32(dr["Transaction_Id"]))
                                            .CopyToDataTable();
                    addObj.PaymentDetailInfo = new List <PaymentDetailInfo>();
                    foreach (DataRow detail in tblFiltered.Rows)
                    {
                        addDetail              = new PaymentDetailInfo();
                        addDetail.Amount       = Convert.ToDecimal(detail["Amount"].ToString());
                        addDetail.CurrencyCode = detail["CurrencyCode"].ToString();
                        addObj.PaymentDetailInfo.Add(addDetail);
                    }
                    results.Add(addObj);
                }
            }


            return(results);
        }
Exemple #3
0
        public Task <List <StudentPaymentInfo> > GetStudentPayment(int batchID, int userID) // 13202, 32184
        {
            return(Task.Run(() =>
            {
                using (MIUEntities db = new MIUEntities())
                {
                    List <MIUPayment> data = db.MIUPayments.Where(x => x.BatchID == batchID && x.StudentID == userID).ToList();

                    List <StudentPaymentInfo> infoList = new List <StudentPaymentInfo>();
                    if (data != null)
                    {
                        foreach (var item in data)
                        {
                            StudentPaymentInfo info = new StudentPaymentInfo();
                            List <PaymentDetailInfo> infoDetailList = new List <PaymentDetailInfo>();
                            PropertyCopier <MIUPayment, StudentPaymentInfo> .Copy(item, info);
                            info.BatchName = item.Batch.BatchName;
                            info.CourseName = item.Course.CourseName;
                            infoList.Add(info);
                            foreach (var item1 in item.MIUPaymentDetails)
                            {
                                PaymentDetailInfo infoDetail = new PaymentDetailInfo();
                                PropertyCopier <MIUPaymentDetail, PaymentDetailInfo> .Copy(item1, infoDetail);
                                if (String.IsNullOrEmpty(item1.PaymentStatus) && item1.PaymentDueDate < DateTime.Now)
                                {
                                    infoDetail.PaymentStatus = "Overdued";
                                }
                                infoDetail.TermName = item1.Term.TermName;
                                infoDetailList.Add(infoDetail);
                            }
                            info.StudentPaymentDetailInfo = infoDetailList;
                        }
                    }

                    return infoList;
                }
            }));
        }
        public List <TransactionInfo> GetGridData(string curCode, DateTime fromdate, DateTime todate, string status)
        {
            List <TransactionInfo> results = new List <TransactionInfo>();
            TransactionInfo        addObj;
            PaymentDetailInfo      addDetail;

            using (Entities entity = new Entities())
            {
                var xml_queriedData = from x in entity.tblExcels.AsEnumerable()
                                      join d in entity.tblXMLPaymentDetails.AsEnumerable() on x.Syskey equals d.XMLId
                                      where d.CurrencyCode == (curCode != string.Empty ? curCode : d.CurrencyCode)
                                      //&& (x.TransDate >= fromdate && x.TransDate <= todate)
                                      && x.RecordStatus == (status != string.Empty ? status : x.RecordStatus)
                                      select new { x, d };
                var xml_distinctData = (from d in xml_queriedData
                                        select new { d.x }).Distinct();
                foreach (var item in xml_distinctData)
                {
                    addObj    = new TransactionInfo();
                    addObj.Id = item.x.TransID;
                    addObj.TransactionDate   = item.x.TransDate;
                    addObj.Status            = item.x.RecordStatus;
                    addObj.PaymentDetailInfo = new List <PaymentDetailInfo>();
                    foreach (var d_item in xml_queriedData.Where(c => c.d.XMLId == item.x.Syskey))
                    {
                        addDetail              = new PaymentDetailInfo();
                        addDetail.Amount       = d_item.d.Amount;
                        addDetail.CurrencyCode = d_item.d.CurrencyCode;
                        addObj.PaymentDetailInfo.Add(addDetail);
                    }
                    results.Add(addObj);
                }


                var csv_queriedData = from x in entity.tblCSVs.AsEnumerable()
                                      join d in entity.tblCSVPaymentDetails.AsEnumerable() on x.Syskey equals d.CSVId
                                      where d.CurrencyCode == (curCode != string.Empty ? curCode : d.CurrencyCode)
                                      //&& (x.TransDate >= fromdate && x.TransDate <= todate)
                                      && x.RecordStatus == (status != string.Empty ? status : x.RecordStatus)
                                      select new { x, d };
                var csv_distinctData = (from d in csv_queriedData
                                        select new { d.x }).Distinct();
                foreach (var item in csv_distinctData)
                {
                    addObj    = new TransactionInfo();
                    addObj.Id = item.x.TransID;
                    addObj.TransactionDate   = item.x.TransDate;
                    addObj.Status            = item.x.RecordStatus;
                    addObj.PaymentDetailInfo = new List <PaymentDetailInfo>();
                    foreach (var d_item in csv_queriedData.Where(c => c.d.CSVId == item.x.Syskey))
                    {
                        addDetail              = new PaymentDetailInfo();
                        addDetail.Amount       = d_item.d.Amount;
                        addDetail.CurrencyCode = d_item.d.CurrencyCode;
                        addObj.PaymentDetailInfo.Add(addDetail);
                    }
                    results.Add(addObj);
                }
            }
            return(results);
        }