public ActionResult SubscriptionTransactionConsumerResult(string tc_)
        {
            ConsumerDataModel consdata = new ConsumerDataModel();

            System.Threading.Thread.Sleep(200);
            consdata.GetConsumerDetailsData(tc_);
            var searchuser = consdata.ConsumerDetails.Where(x => x.tc_id == tc_).FirstOrDefault();

            if (searchuser != null)
            {
                consdata.GetConsumerInvoiceDetails(tc_);
                consdata.GetConsumerUnpaidInvoices(tc_);


                ViewBag.usern       = searchuser.username;
                ViewBag.name        = searchuser.name;
                ViewBag.surn        = searchuser.surname;
                ViewBag.tckn        = searchuser.tc_id;
                ViewBag.phn         = searchuser.phone;
                ViewBag.mail        = searchuser.email;
                ViewBag.unpaidcount = consdata.ConsumerUnpaidInvoices.Count(y => y.ispaid == false);

                return(View(consdata));
            }
            else
            {
                TempData["result"] = "<script>alert('Kullanıcı bulunamadı');</script>";
                return(RedirectToAction("SearchConsumerSubscriber"));
            }
        }
        public ActionResult ConsumerLogin(ConsumerLoginModel cons)
        {
            var consdata = new ConsumerDataModel();

            System.Threading.Thread.Sleep(200);
            consdata.GetConsumerData();
            var searchuser = consdata.ConsumerData.Where(x => x.tc_id == cons.TC_id).SingleOrDefault();

            if (searchuser != null)
            {
                FormsAuthentication.SetAuthCookie("TC_id", false);
                return(RedirectToAction("Index", "ConsumerBill", new { tc = searchuser.tc_id.ToString() }));
            }
            {
                ViewBag.ErrorMessage = "Kullanıcı bulunamadı. Lütfen blgilerinizi kontrol ediniz.";
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult SearchConsumerSubscriberResult(string tc_)
        {
            ConsumerDataModel consdata = new ConsumerDataModel();

            System.Threading.Thread.Sleep(200);
            consdata.GetConsumerDetailsData(tc_);
            var searchuser = consdata.ConsumerDetails.Where(x => x.tc_id == tc_).FirstOrDefault();

            if (searchuser != null)
            {
                consdata.GetConsumerInvoiceDetails(tc_);
                TempData["result"] = "Username:"******", Name:" + searchuser.name + ", Surname:" + searchuser.surname + ", TCno:" + searchuser.tc_id + ", Phone:" + searchuser.phone + ", Email:" + searchuser.email;
                return(View(consdata));
            }
            else
            {
                TempData["result"] = "<script>alert('Kullanıcı bulunamadı');</script>";
                return(RedirectToAction("SearchConsumerSubscriber"));
            }
        }
        //[OutputCache(Duration = 180, VaryByParam = "*", Location = System.Web.UI.OutputCacheLocation.Server)]
        public ActionResult Index(string tc)
        {
            ConsumerDataModel consmodel = new ConsumerDataModel();

            System.Threading.Thread.Sleep(200);
            consmodel.GetConsumerBillRawData();
            var searchuser2 = consmodel.ConsumerBillRawData.Where(y => y.tc_id == tc).FirstOrDefault();

            if (searchuser2 != null)
            {
                consmodel.GetConsumerPaidInvoices(tc);
                consmodel.GetConsumerUnpaidInvoices(tc);
            }
            else
            {
                TempData["Message"] = "<script>alert('Kayıt bulunamadı');</script>";
            }



            return(View(consmodel));
        }
        public ActionResult CreateNewConsumerSubscriber(string username1, string conname, string surname, string tc, string conphone, string conemail, string conpass, bool conisactive)
        {
            CreateDeleteSubscriberModel sub      = new CreateDeleteSubscriberModel();
            ConsumerDataModel           consdata = new ConsumerDataModel();

            consdata.GetConsumerData();

            System.Threading.Thread.Sleep(200);
            var searchuser = consdata.ConsumerData.Where(x => x.username == username1).SingleOrDefault();

            if (searchuser != null)
            {
                TempData["Message"] = "<script>alert('Bu kayıt zaten mevcut!');</script>";
                return(RedirectToAction("CreateNewSubscriber"));
            }
            else
            {
                sub.AddNewConsumer(username1, conname, surname, tc, conphone, conemail, conpass, conisactive);
                sub.AddNewConsumerInDeposit(tc);
                TempData["Message"] = "<script>alert('Başarılı bir şekilde sisteme eklendi');</script>";
                return(RedirectToAction("CreateNewSubscriber"));
            }
        }
        public ActionResult CloseConsumerAccount(string tc_)
        {
            ConsumerDataModel consdata = new ConsumerDataModel();

            System.Threading.Thread.Sleep(200);
            consdata.GetConsumerBillRawData();
            var searchuser = consdata.ConsumerBillRawData.Where(y => y.tc_id == tc_).FirstOrDefault();


            if (searchuser != null)
            {
                consdata.GetConsumerPayDeposit(tc_);
                consdata.GetConsumerDetailsData(tc_);
                consdata.GetConsumerAccountClose(tc_);
                ViewBag.IsReload = true;
                return(RedirectToAction("SubscriptionTransaction", "AdminOperations"));
            }
            else
            {
                ViewBag.message = "<p style='color:red;'>Abonelik kapatma işlemi başarısız oldu.</p>";
                return(RedirectToAction("SubscriptionTransactionConsumerResult", "AdminOperations", new { tc_ = searchuser.tc_id.ToString() }));
            }
        }
        public ActionResult PayInvoiceConsumer_(string tc_, int id)
        {
            ConsumerDataModel consmodel = new ConsumerDataModel();

            System.Threading.Thread.Sleep(200);
            consmodel.GetConsumerBillRawData();
            var searchuser  = consmodel.ConsumerBillRawData.Where(x => x.bill_id == id).FirstOrDefault();
            var searchuser2 = consmodel.ConsumerBillRawData.Where(y => y.tc_id == tc_).FirstOrDefault();

            if (searchuser != null && searchuser2 != null)
            {
                consmodel.GetConsumerPayInvoice(id);
                consmodel.GetConsumerPaidInvoices(tc_);
                consmodel.GetConsumerUnpaidInvoices(tc_);
                TempData["Message"] = "<script>alert('Fatura ödeme işlemi tamamlandı');</script>";
                ViewBag.IsReload    = true;
                return(RedirectToAction("SearchConsumerSubscriberResult", "AdminOperations", new { tc_ = searchuser2.tc_id.ToString() }));
            }
            else
            {
                return(RedirectToAction("SearchConsumerSubscriberResult", "AdminOperations", new { tc_ = searchuser2.tc_id.ToString() }));
            }
        }