Ejemplo n.º 1
0
        public IActionResult DistributionDetails()
        {
            int serialno         = 1;
            var distributioninfo = dbc.MealDistribution.Where(q => q.Date.Month == DateTime.Now.Month).ToList();
            var count            = (from d in distributioninfo
                                    group d by(d.StudentHallID) into dl
                                    from a in dl
                                    select new
            {
                id = dl.Key,
                name = a.StudentName,
                total = dl.Count(),
                totaltrue = dl.Count(q => q.DistributionStatus == true),
                totalfalse = dl.Count(q => q.DistributionStatus == false),
            }).Distinct();
            var list = new List <MealDistributionViewModel>();

            foreach (var item in count)
            {
                MealDistributionViewModel distributionvm = new MealDistributionViewModel();
                distributionvm.serialnoVM = serialno;
                serialno++;
                distributionvm.studenthallidVM = item.id;
                distributionvm.studentnameVM   = item.name;
                distributionvm.status2         = (item.totaltrue * 100) / item.total;
                distributionvm.meal            = item.total;
                list.Add(distributionvm);
            }
            return(View(list));
        }
Ejemplo n.º 2
0
        public IActionResult DinnerHour()
        {
            int serialno             = 1;
            var student              = dbc.Payment.Where(q => q.Date.Month == DateTime.Now.Month).ToList();
            var listmealdistribution = new List <MealDistributionViewModel>();

            foreach (var item in student)
            {
                MealDistributionViewModel distribution = new MealDistributionViewModel();
                distribution.serialnoVM = serialno;
                serialno++;
                distribution.studenthallidVM = item.StudentHallID;
                distribution.studentnameVM   = item.StudentName;
                distribution.dateVM          = DateTime.Now;
                listmealdistribution.Add(distribution);
            }
            return(View(listmealdistribution));
        }
        public IActionResult MyMealActivity()
        {
            var student = HttpContext.Session.GetString("UserID");
            var id      = Convert.ToInt32(student);
            var c       = dbc.MealDistribution.Where(q => q.Date.Month == DateTime.Now.Month && q.StudentHallID == id).ToList();
            var count   = (from i in c
                           group i by(i.StudentHallID) into l
                           from list in l
                           select new
            {
                id = list.StudentHallID,
                name = list.StudentName,
                total = l.Count(),
                totaltrue = l.Count(q => q.DistributionStatus == true)
            }).FirstOrDefault();
            MealDistributionViewModel status = new MealDistributionViewModel();

            status.studenthallidVM = count.id;
            status.studentnameVM   = count.name;
            status.meal            = count.total;
            status.status2         = (count.totaltrue * 100) / count.total;
            return(View(status));
        }