Пример #1
0
        public ActionResult SalesDish(ReportLocal model)
        {
            var identity = (System.Web.HttpContext.Current.User as MyIdentity.MyPrincipal).Identity as MyIdentity;
            List <ReportLocalResult> resultArray = new List <ReportLocalResult>();

            foreach (var tmp in db.PR_DishSalesReport(model.RestaurantId, DateTime.Parse(model.DateStart), DateTime.Parse(model.DateEnd).AddDays(1)))
            {
                ReportLocalResult resultTmp = new ReportLocalResult
                {
                    DishResult  = db.Dish.Find(tmp.ID),
                    SalesResult = (int)tmp.Quantity,
                    TotalResult = (decimal)tmp.Total
                };
                resultArray.Add(resultTmp);
            }

            var newModel = new ReportLocal
            {
                Restaurants  = new SelectList(db.PR_LocalRestaurantInfo(identity.User.IdCard).ToList(), "IdLocal", "Name"),
                RestaurantId = model.RestaurantId,
                DateStart    = model.DateStart,
                DateEnd      = model.DateEnd,
                Top          = model.Top,
                Result       = resultArray,
                Types        = db.PR_DishTypes().ToList()
            };


            return(View(newModel));
        }