Exemplo n.º 1
0
 public ActionResult ShowAllSales(int?manager, string product, string date)
 {
     using (IPL db = new PL())
     {
         IEnumerable <SaleViewModel> sales    = db.GetSales();
         IList <ManagerViewModel>    managers = db.GetManagers().ToList();
         managers.Insert(0, new ManagerViewModel {
             ManagerID = 0, LastName = "Все"
         });
         IList <string> products = sales.Select(x => x.Product).Distinct().ToList();
         products.Insert(0, "Любой");
         IList <DateTime> dates          = sales.Select(x => x.Date).Distinct().ToList();
         IList <string>   datesForFilter = new List <string>();
         foreach (var item in dates)
         {
             datesForFilter.Add(String.Format("{0:d}", item));
         }
         datesForFilter.Insert(0, "Даты нет");
         datesForFilter = datesForFilter.Distinct().ToList();
         FilterModel filter = new FilterModel
         {
             Sales    = sales,
             Managers = new SelectList(managers, "ManagerId", "LastName"),
             Products = new SelectList(products),
             Dates    = new SelectList(datesForFilter)
         };
         return(View(filter));
     }
 }
Exemplo n.º 2
0
 public ActionResult ShowAllManagers()
 {
     using (IPL db = new PL())
     {
         ViewBag.Managers = db.GetManagers();
     }
     return(View());
 }
Exemplo n.º 3
0
        public JsonResult DrawChart()
        {
            ICollection <Models.ManagerChartModel> data = new List <Models.ManagerChartModel>();

            using (IPL db = new PL())
            {
                var sales    = db.GetSales();
                var managers = db.GetManagers();
                foreach (var item in managers)
                {
                    data.Add(new ManagerChartModel {
                        ManagerName = item.LastName, NumberOfSales = sales.Where(x => x.ManagerId == item.ManagerID).Count()
                    });
                }
            }
            return(Json(new { Data = data }, JsonRequestBehavior.AllowGet));
        }