public ActionResult Index() { try { int GYM_ID = Convert.ToInt32(Session["GYM_ID"]); var Branche = db.Branches.Where(i => i.GYM_ID == GYM_ID).OrderByDescending(i => i.ID).ToList(); List <BranchTotalModel> BranchTotalModelList = new List <BranchTotalModel>(); foreach (var d in Branche) { BranchTotalModel BranchTotalModel = new BranchTotalModel(); BranchModel BranchModel = new BranchModel(); CountryModel CountryModel = new CountryModel(); StateModel stateModel = new StateModel(); CityModel cityModel = new CityModel(); var Country = db.Countries.Where(i => i.ID == d.Country_ID).FirstOrDefault(); CountryModel.CountryNames = Country.CountryNames; var State = db.States.Where(i => i.ID == d.State_ID).FirstOrDefault(); stateModel.StateName = State.StateName; var City = db.Cities.Where(i => i.ID == d.City_ID).FirstOrDefault(); cityModel.City_Name = City.City_Name; BranchModel.Area = d.Area; BranchModel.City_ID = d.City_ID; BranchModel.Building_Name = d.Building_Name; BranchModel.Country_ID = d.Country_ID; BranchModel.ID = d.ID; BranchModel.IS_Active = d.IS_Active; BranchModel.Landmark = d.Landmark; BranchModel.Name = d.Name; BranchModel.Pin_Code = d.Pin_Code; BranchModel.State_ID = d.State_ID; BranchTotalModel.Branch = BranchModel; BranchTotalModel.Country = CountryModel; BranchTotalModel.City = cityModel; BranchTotalModel.State = stateModel; BranchTotalModelList.Add(BranchTotalModel); } return(View(BranchTotalModelList)); } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }
public ActionResult Owner() { try { int GYM_ID = Convert.ToInt32(Session["GYM_ID"]); var Branche = db.Branches.Where(i => i.GYM_ID == GYM_ID && i.IS_Active == true).ToList(); List <BranchTotalModel> BranchTotalModelList = new List <BranchTotalModel>(); ViewBag.Total_Student = db.Students.Where(i => i.GYM_ID == GYM_ID).Count(); ViewBag.Total_Trainer = db.Trainers.Where(i => i.Role_ID == 3 && i.GYM_ID == GYM_ID).Count(); ViewBag.Total_Manager = db.Trainers.Where(i => i.Role_ID == 2 && i.GYM_ID == GYM_ID).Count(); ViewBag.Total_Branch = db.Branches.Where(i => i.GYM_ID == GYM_ID && i.IS_Active == true).Count(); ViewBag.Total_Offer = db.Offers.Where(i => i.GYM_ID == GYM_ID && i.Status == true).Count(); ViewBag.Total_Plane = db.Planes.Where(i => i.GYM_ID == GYM_ID && i.Is_Active == true).Count(); ViewBag.Visit = db.Demoes.Where(i => i.GYM_ID == GYM_ID && DbFunctions.TruncateTime(i.Date) == DbFunctions.TruncateTime(DateTime.Now)).Count(); ViewBag.Today_Joining = db.Demoes.Where(d => DbFunctions.TruncateTime(d.Date) == DbFunctions.TruncateTime(DateTime.Now) && d.GYM_ID == GYM_ID).Count(); ViewBag.New_Student = db.Students.Where(d => DbFunctions.TruncateTime(d.Start_Date) == DbFunctions.TruncateTime(DateTime.Now) && d.GYM_ID == GYM_ID).Count(); var Today_Earning = db.Fees.Where(i => i.GYM_ID == GYM_ID && DbFunctions.TruncateTime(i.Payment_Date) == DbFunctions.TruncateTime(DateTime.Now)).ToList(); var Earning = 0; foreach (var Earnings in Today_Earning) { Earning = Earning + Convert.ToInt32(Earnings.Payment_Amount); } ViewBag.Today_Earning = Earning; var Month_Earnings = db.Fees.Where(i => i.GYM_ID == GYM_ID && i.Payment_Date.Value.Month == DateTime.Now.Month).ToList(); var Earningss = 0; foreach (var Month_Earning in Month_Earnings) { Earningss = Earningss + Convert.ToInt32(Month_Earning.Payment_Amount); } ViewBag.Month_Earning = Earningss; foreach (var d in Branche) { BranchTotalModel BranchTotalModel = new BranchTotalModel(); BranchModel BranchModel = new BranchModel(); TotalModel TotalModel = new TotalModel(); BranchModel.ID = d.ID; BranchModel.Name = d.Name; TotalModel.Student = db.Students.Where(i => i.Branch_ID == d.ID).Count(); TotalModel.Trainer = db.Trainers.Where(i => i.Branvch_ID == d.ID && i.Role_ID == 3).Count(); TotalModel.Manager = db.Trainers.Where(i => i.Branvch_ID == d.ID && i.Role_ID == 2).Count(); TotalModel.Plane = db.Branch_Wise_Plane.Where(i => i.Branch_ID == d.ID && i.Status == true).Count(); TotalModel.Offer = db.Branch_Wise_Offer.Where(i => i.Branch_ID == d.ID && i.Status == true).Count(); TotalModel.Demo = db.Demoes.Where(i => i.Branch_ID == d.ID && DbFunctions.TruncateTime(i.Date) == DbFunctions.TruncateTime(DateTime.Now)).Count(); ViewBag.Today_Joining = db.Demoes.Where(i => DbFunctions.TruncateTime(i.Start_Date) == DbFunctions.TruncateTime(DateTime.Now) && i.Branch_ID == d.ID).Count(); ViewBag.New_Student = db.Students.Where(i => DbFunctions.TruncateTime(i.Start_Date) == DbFunctions.TruncateTime(DateTime.Now) && i.Branch_ID == d.ID).Count(); TotalModel.Today_Earning = Earning; TotalModel.Month_Earning = Earningss; BranchTotalModel.Total = TotalModel; BranchTotalModel.Branch = BranchModel; BranchTotalModelList.Add(BranchTotalModel); } return(View(BranchTotalModelList)); } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }