Example #1
0
        public static int CalculateAgeInYears(DateTime?birthDate)
        {
            DateTime now   = DateTime.Now;
            DateTime bdate = ValueConverters.ConvertNullToDatetime(birthDate);
            int      age   = now.Year - bdate.Year;

            if (now.Month < bdate.Month || (now.Month == bdate.Month && now.Day < bdate.Day))
            {
                age--;
            }

            return(age);
        }
Example #2
0
        private void GetAccountClosureHistory(CustomerAccountsView customerAccountsDetails)
        {
            customerAccountsDetails.ClosedAccountDetails = new List <PostingJournalsHeaderViewModel>();
            var closeDetails = mainDb.tbl_PostingJournals
                               .Where(x => (x.PostingDocid == "ACRS" || x.PostingDocid == "ACLS") &&
                                      x.AccountNo == customerAccountsDetails.AccountNo)
                               .ToList();


            if (closeDetails != null)
            {
                foreach (var item in closeDetails)
                {
                    PostingJournalsHeaderViewModel lineItem = new PostingJournalsHeaderViewModel();

                    lineItem.PostingDescription = ValueConverters.ConvertNullToEmptyString(item.PostingDescription);
                    lineItem.PostDate           = ValueConverters.ConvertNullToDatetime(item.PostDate);
                    lineItem.PostedBy           = ValueConverters.ConvertNullToEmptyString(item.PostedBy);
                    lineItem.CreateDate         = ValueConverters.ConvertNullToDatetime(item.CreateDate);
                    lineItem.CreatedBy          = ValueConverters.ConvertNullToEmptyString(item.CreatedBy);
                    lineItem.PaymentMethodName  = item.PostingDocid == "ACLS" ? "Closure" : "Rejoin";

                    var opennedBy = mainDb.tbl_users.FirstOrDefault(x => x.LoginCode == lineItem.PostedBy);
                    if (opennedBy != null)
                    {
                        lineItem.PostedByName = ValueConverters.ConvertNullToEmptyString(opennedBy.LoginName);
                    }
                    opennedBy = mainDb.tbl_users.FirstOrDefault(x => x.LoginCode == lineItem.CreatedBy);
                    if (opennedBy != null)
                    {
                        lineItem.CreatedByName = ValueConverters.ConvertNullToEmptyString(opennedBy.LoginName);
                    }
                    customerAccountsDetails.ClosedAccountDetails.Add(lineItem);
                }
            }
        }