public JsonResult GetFriendCallDetailsPrep([DataSourceRequest] DataSourceRequest request, int dateIndex, string friendFbId)
        {
            IList <DateTime> dateRange = CallDetailsModel.GetDateRange();
            string           startDate = String.Format("{0:dd'/'MM'/'yyyy}", dateRange[dateIndex + 1]);
            string           endDate   = String.Format("{0:dd'/'MM'/'yyyy}", dateRange[dateIndex]);

            ServiceManager.ServiceHandlers.CallDetailHandler srvHandler = new CallDetailHandler();

            var srvData = srvHandler.PrepareData(startDate, endDate);

            IList <CallDetailModel> modelList = (from u in srvData
                                                 join p in UserFb.Friends on LIB.StringHelper.Right(u.OpAddress.TrimEnd(), 10) equals p.Msisdn
                                                 into a
                                                 from f in a.DefaultIfEmpty(new UserFbFriendModel())
                                                 select new CallDetailModel
            {
                Amount = u.Amount,
                DataVolume = u.DataVolume,
                DateDisplay = u.DateDisplay,
                Description = u.Description,
                OpAddress = ProjectUtil.CallDetailOpAddres(u.OpAddress, session.IsSubscriptionActive),
                PictureLink = f.PictureLink,
                UserId = f.UserId,
                FbId = f.FbId,
                FirstNameView = f.FirstNameView,
                IsClickToCallBlock = f.IsClickToCallBlock,
                IsClickToCallInvisible = f.IsClickToCallInvisible,
                LastNameView = f.LastNameView,
            })
                                                .Where(f => f.FbId == friendFbId)
                                                .ToList();

            return(Json(modelList.ToList(), JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetFriendCallDetailsPosp([DataSourceRequest] DataSourceRequest request, string Period, string friendFbId)
        {
            ServiceManager.ServiceHandlers.CallDetailHandler srvHandler = new CallDetailHandler();
            srvHandler.customerType = (Parameter.CustomerType)UserFb.Data.CustomerType;

            var srvData = srvHandler.PrepareData(Period);

            IList <CallDetailModel> modelList = (from u in srvData
                                                 join p in UserFb.Friends on LIB.StringHelper.Right(u.OpAddress.TrimEnd(), 10) equals p.Msisdn
                                                 into a
                                                 from f in a.DefaultIfEmpty(new UserFbFriendModel())
                                                 select new CallDetailModel
            {
                Amount = u.Amount,
                DataVolume = u.DataVolume,
                DateDisplay = u.DateDisplay,
                Description = u.Description,
                OpAddress = ProjectUtil.CallDetailOpAddres(u.OpAddress, session.IsSubscriptionActive),

                PictureLink = f.PictureLink,
                UserId = f.UserId,
                FbId = f.FbId,
                FirstNameView = f.FirstNameView,
                IsClickToCallBlock = f.IsClickToCallBlock,
                IsClickToCallInvisible = f.IsClickToCallInvisible,
                LastNameView = f.LastNameView,
            })
                                                .Where(f => f.FbId == friendFbId)
                                                .ToList();

            return(Json(modelList.ToList(), JsonRequestBehavior.AllowGet));
        }
        //Postpaid ve prepaid hatlar icin
        public PartialViewResult TopCalledNumbers(string invoiceNumber)
        {
            var model   = new EnCokArananArkadaslarModel();
            var handler = new CokArananNumaralarHandler();

            model.serviceData = invoiceNumber == null?handler.PrepareData() : handler.PrepareData(invoiceNumber);

            try
            {
                foreach (var item in model.serviceData)
                {
                    if (item.Msisdn == "topCalledNumbers")
                    {
                        model.serviceData = null;
                        break;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            //Subscription sorgusu yapan ufak kisim.
            //özellikle try-catch içerisinde tutuyoruz ki bu küçük sorgu
            //patlasa bile asıl modül çalışmaya devam etsin.
            try
            {
                var subscriptionHandler = new CallDetailHandler();
                var subscriptionStatus  = subscriptionHandler.GetSubscriptionStatus((Com.Enums.Parameter.UserType)UserFb.Data.UserType);

                session.IsSubscriptionActive = subscriptionStatus;
            }
            catch (Exception) { }

            //Birinci join, servisten gelen MSISDN ler icerisinde user'in arkadaslari olup
            //olmadigini joinliyor. Ayni msisdn birden fazla arkadas kaydina denk gelebilecegi
            //icin burada outer join yapiyoruz ve merge etmeden join edilmis kayitlari aliyoruz
            //ki duplicate kayit gelmesin.
            var friendsTableJoin = (from u in model.serviceData
                                    join p in UserFb.Friends on u.Msisdn equals p.Msisdn
                                    into a
                                    from f in a.DefaultIfEmpty(new UserFbFriendModel {
                Msisdn = u.Msisdn
            })
                                    select f).ToList();

            IList <EnCokArananlarMergeModel> mergeModel = (from u in friendsTableJoin
                                                           where u.IsClickToCallInvisible == false && u.IsClickToCallBlock == false
                                                           select new EnCokArananlarMergeModel
            {
                FbId = u.FbId,
                FirstNameView = u.FirstName == null ? String.Empty : LIB.FormatHelper.NameCharLimit(u.FirstName.ToString(), GlobalVars.NameCharLimit, GlobalVars.NameExtChars),
                LastNameView = u.LastName == null ? String.Empty : LIB.FormatHelper.NameCharLimit(u.LastName.ToString(), GlobalVars.NameCharLimit, GlobalVars.NameExtChars),
                Msisdn = u.Msisdn,
                PictureLink = u.PictureLink,
                UserId = u.UserId,
                IsClickToCallBlock = u.IsClickToCallBlock,
                IsClickToCallInvisible = u.IsClickToCallInvisible
            }).Take(5).ToList();

            return(PartialView(mergeModel));
        }