public ActionResult billgenerator() { List <ADM_M_BILLINGPRODUCTS> output1 = new List <ADM_M_BILLINGPRODUCTS>(); if (Session["UserName"] != null) { AdityamineralsEntities dbObj = new AdityamineralsEntities(); var output = dbObj.ADM_L_BILLINGPART1.Count(); if (output == 0) { DashboardBL obj = new DashboardBL(); output1 = obj.getproductslist(); ViewBag.invoiceno = 1; } else { var op = dbObj.ADM_L_BILLINGPART1.Select(c => c.InvoiceNo).DefaultIfEmpty(0).Max(); ViewBag.invoiceno = op + 1; DashboardBL obj = new DashboardBL(); output1 = obj.getproductslist(); } return(View(output1)); } else { return(RedirectToAction("Login", "Login")); } }