Mzsmunna
10/18/2019 - 2:39 PM

Random Codes Snips of C#

List<dynamic> dynamicObjectList = new List<dynamic>();

dynamic dynamicProspect = new ExpandoObject(); // ExpandoObject class is under System.Dynamic namespace

dynamicProspect.FIRST_NAME = antherObject.FirstName;

----------------------------------

private List<NoticeMember> GetNoticeMember(NoticeDetails noticeMember)
{
    List<NoticeMember> results = new List<NoticeMember>();
    var members = _payspanRepository.GetMemberListByProvider(noticeMember.SRC_PROVIDER_ID, false).Result;

    var memberGroup = members.GroupBy(x => new { x.SRC_MBR_ID, x.MBR_PERS_GEN_KEY, x.MBR_FIRST_NAME, x.MBR_LAST_NAME, x.MBR_DOB })
                             .Select(x => new { x.Key.MBR_PERS_GEN_KEY, x.Key.SRC_MBR_ID, x.Key.MBR_FIRST_NAME, x.Key.MBR_LAST_NAME, x.Key.MBR_DOB })
                             .ToList();
    memberGroup.ForEach(x =>
    {
        results.Add(new NoticeMember
        {
            MemberNoticeNumber = x.MBR_PERS_GEN_KEY,
            MemberID = x.SRC_MBR_ID,
            MemberFirst = x.MBR_FIRST_NAME,
            MemberLast = x.MBR_LAST_NAME,
            DOB = x.MBR_DOB,
            //NoticeHCCs = GetNoticeHCC(row, headers),
            //NoticeDXs = GetNoticeDX(row, headers),
            NoticeCareGaps = GetNoticeCareGap(members.Where(xx => xx.SRC_MBR_ID == x.SRC_MBR_ID).ToList())
        });
    });

    return results;
}

-----------------------------------

var qsvList = providerDetails.GroupBy(x => new { x.PROV_TAX_ID, x.PROV_GRP_NAME })
                            .Select(x => new { TaxId = x.Key.PROV_TAX_ID, GrpName = x.Key.PROV_GRP_NAME })
                            .ToList();
                            
-----------------------------------------


string line;
    List listOfPersons=new List();

    // Read the file and display it line by line.
    System.IO.StreamReader file = 
        new System.IO.StreamReader(@"c:\yourFile.txt");
    while((line = file.ReadLine()) != null)
    {
        string[] words = line.Split(',');
        listOfPersons.Add(new Person(words[0],words[1],words[2]));
    }

    file.Close();
    
    
//----------------------------- Read delimiter text line by line and save into array or list!!

// Read the data.txt textfile.
var data = System.IO.File.ReadAllText("Data.txt");

// Create a new List of float[]
var arrays = new List<float[]>();

// Split data file content into lines
var lines = data.Split(new[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries);

// Loop all lines
foreach (var line in lines)
{
    // Create a new List<float> representing all the commaseparated numbers in this line
    var lineArray = new List<float>();

    // Slipt line by , and loop through all the numeric valus
    foreach (var s in line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries))
    {
        // Add converted numeric value to our lineArray 
        lineArray.Add(Convert.ToInt64(s));
    }
    // Add lineArray to main array
    arrays.Add(lineArray.ToArray());

    // Loop repeats until there are noe more lines
}


-----------------------------

    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("Enter Your Name :");
            //string name = Console.ReadLine();
            //Console.WriteLine("Hello " + name);

            List<string> lines = new List<string>();
            List<string> arrays = new List<string>();
            List<PayspanRegister> results = new List<PayspanRegister>();

            using (TextReader rdr = new StreamReader(@"E:\PsRgTEST_BONUS.txt"))
            {
                string line;               

                while ((line = rdr.ReadLine()) != null)
                {
                    // use line here
                    lines.Add(line);
                }
            }

            var headers = lines.FirstOrDefault();
            lines.RemoveAt(0);

            for (int i = 0; i < lines.Count; i++)
            {
                string[] words = lines[i].Split(',');

                PayspanRegister pr = new PayspanRegister();

                pr.PaymentDate = words[0];
                pr.PaymentEffectiveDate = words[1];
                pr.TraceNumber = words[2];
                pr.PaymentMethod = words[3];
                pr.RecipientIdNumber = words[4];
                pr.PayeeID = words[5];
                pr.PayeeTaxID = words[6];
                pr.PayeeNPI = words[7];
                pr.PayeeName = words[8];
                pr.PaymentAmount = words[9];
                pr.PaymentCode = words[10];
                pr.PayspanJobID = words[11];

                results.Add(pr);
            }

            Console.ReadKey();
        }
    }

    class PayspanRegister
    {
        public string PaymentDate { get; set; }
        public string PaymentEffectiveDate { get; set; }
        public string TraceNumber { get; set; }
        public string PaymentMethod { get; set; }
        public string RecipientIdNumber { get; set; }
        public string PayeeID { get; set; }
        public string PayeeTaxID { get; set; }
        public string PayeeNPI { get; set; }
        public string PayeeName { get; set; }
        public string PaymentAmount { get; set; }
        public string PaymentCode { get; set; }
        public string PayspanJobID { get; set; }
    }
    
    -----------------------------------------------
    
    // Convert One Object to Another using Newtonsoft.Json NUGET PACKAGE
    var backupResponseObject = JsonConvert.DeserializeObject<CareplanBackupResponse>(JsonConvert.SerializeObject(responseObject));