Exemplo n.º 1
0
        public static IList <BO_SubCustomer> LoadSubscription(JQueryDataTableParamModel Param)
        {
            List <BO_SubCustomer> lst_subTable = new List <BO_SubCustomer>();

            using (AprosysAccountingEntities db_aa = new AprosysAccountingEntities())
            {
                BO_SubCustomer obj;

                var lst       = db_aa.GetSubscriptionList();
                var reminders = db_aa.Reminders.Where(x => x.LastReminderSentDate.HasValue).Select(x => new { x.SubscriptionID, x.LastReminderSentDate }).GroupBy(x => x.SubscriptionID).ToDictionary(x => x.Key);
                foreach (var item in lst.ToList())
                {
                    obj                    = new BO_SubCustomer();
                    obj.subid              = item.subid;
                    obj.lastName           = item.LastName;
                    obj.firstName          = item.FirstName;
                    obj.phone              = item.Phone;
                    obj.subscriptionAmount = item.SubscriptionAmount;
                    obj.dueDate            = item.DueDate;
                    obj.startDate          = item.StartDate;
                    obj.subStatus          = item.SubStatus ?? false;
                    obj.subscriptionStatus = (item.SubStatus == true ? "Suspended" : "Active");
                    if (obj.subStatus)
                    {
                        //obj.subDisableStartDate = item.SubDisableStartDate;
                        //obj.subDisableEndDate = item.SubDisableEndDate;
                    }
                    if (reminders.ContainsKey(item.subid))
                    {
                        obj.subLastReminderSent = reminders[item.subid].OrderByDescending(x => x.LastReminderSentDate).First().LastReminderSentDate.Value;
                    }
                    lst_subTable.Add(obj);
                }
            }
            if (Param.SearchType != 0)
            {
                //if (Param.SearchType == 1)// && Param.SearchValue != null && Param.SearchValue != " ")
                //{
                //    List = List.Where(x => x.name.ToLower().Contains(Param.SearchValue.Trim().ToLower())).ToList();
                //}
                //else if (Param.SearchType == 2)// && Param.SearchValue != null && Param.SearchValue != " ")
                //{
                //    List = List.Where(x => x.itemCode.ToLower().Contains(Param.SearchValue.Trim().ToLower())).ToList();

                //}
            }

            List <BO_SubCustomer> ListtoReturn = new List <BO_SubCustomer>();

            ListtoReturn = lst_subTable;
            return(ListtoReturn);
        }