// GET: Cuahang/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            Cuahang             cuahangs = null;
            HttpResponseMessage response = await client.GetAsync(url + @"Cuahang/" + id);

            if (response.IsSuccessStatusCode)
            {
                cuahangs = await response.Content.ReadAsAsync <Cuahang>();

                //dong hoac mo data table
                ViewBag.accept = false;

                //lấy danh mục cửa hàng=>>
                // Call api
                HttpResponseMessage responseMessage = await client.GetAsync(url + @"DanhMucDoAn/");

                // Get all data
                List <DanhMucDoAn> danhmucdoans = DanhMucDoAnController.getAllDanhMuc(responseMessage);
                // Check data
                danhmucdoans      = danhmucdoans.Where(n => n.MaCH == id).ToList();
                ViewBag.danhmuc   = danhmucdoans;
                ViewBag.CountMenu = danhmucdoans.Count;
                responseMessage   = await client.GetAsync(url + @"Doan");

                List <DoAn> listda = DoAnController.getAllDoAn(responseMessage);
                listda            = listda.Where(n => n.MaDM == id).ToList();
                ViewBag.doan      = listda;
                ViewBag.CountDoan = listda.Count;
                //lấy khuyến mãi của cửa hàng ->>>

                responseMessage = await client.GetAsync(url + @"Khuyenmai/");

                List <Khuyenmai> listkm = KhuyenmaiController.getAllKhuyenmai(responseMessage);
                listkm            = listkm.Where(n => n.MaCH == id).ToList();
                ViewBag.sale      = listkm;
                ViewBag.CountSale = listkm.Count;
                //don hang
                responseMessage = await client.GetAsync(url + @"DonDatHang/");

                List <DonDatHang> listddh = DonDatHangController.getAllOrder(responseMessage);
                listddh             = listddh.Where(n => n.MaKH == id).ToList();
                ViewBag.Donhang     = listddh;
                ViewBag.CountOrders = listddh.Count;
                //sasa
            }
            return(View(cuahangs));
        }
示例#2
0
        // GET: Admin
        public async Task <ActionResult> Index()
        {
            ViewBag.accept = false;
            if (Session["Taikhoanadmin"] == null)
            {
                return(RedirectToAction("SignIn"));
            }
            HttpResponseMessage responseMessage = await client.GetAsync(url + @"dondathang/");

            List <DonDatHang> list = DonDatHangController.getAllOrder(responseMessage);

            ViewBag.CountOrder = list.Count;

            String dataChart = "";

            // data = ''
            dataChart += list.Where(n => int.Parse(n.TinhTrangDonHang) == Constants.STATUS_ORDER_CONFIRM).Count() + ",";
            // data = '2,'
            dataChart += list.Where(n => int.Parse(n.TinhTrangDonHang) == Constants.STATUS_ORDER_DELIVERY).Count() + ",";
            // data = '2,1,'
            dataChart += list.Where(n => int.Parse(n.TinhTrangDonHang) == Constants.STATUS_ORDER_DELIVERED).Count() + ",";
            // data = '2,1,1'
            dataChart += list.Where(n => int.Parse(n.TinhTrangDonHang) == Constants.STATUS_SHIP_BOOM).Count();

            ViewBag.DataChart = dataChart;


            responseMessage = await client.GetAsync(url + @"khachhang/");

            List <KhachHang> listkh = KhachHangController.getAllCustomer(responseMessage);

            ViewBag.CountCustomer = listkh.Count;

            responseMessage = await client.GetAsync(url + @"chitietdonhang/");

            List <ChiTietDonHang> listctdh = getAllDetailOrder(responseMessage);

            ViewBag.revenue = getRevenue(listctdh);

            responseMessage = await client.GetAsync(url + @"nhanviengiaohang/");

            List <NhanVienGiaoHang> listnv = NhanVienGiaoHangController.getAllNhanVienGH(responseMessage);

            ViewBag.CountShipper = listnv.Count;

            responseMessage = await client.GetAsync(url + @"cuahang/");

            List <Cuahang> listch = CuahangController.getAllCuaHang(responseMessage);

            ViewBag.CountStore = listch.Count;

            responseMessage = await client.GetAsync(url + @"doan/");

            List <DoAn> listda = DoAnController.getAllDoAn(responseMessage);

            ViewBag.CountFood = listda.Count;

            responseMessage = await client.GetAsync(url + @"danhmucdoan/");

            List <DanhMucDoAn> listdm = DanhMucDoAnController.getAllDanhMuc(responseMessage);

            ViewBag.CountMenu = listdm.Count;

            responseMessage = await client.GetAsync(url + @"vitrigiaohang/");

            List <ViTriGiaoHang> listvt = ViTriGiaoHangController.getAllPosition(responseMessage);

            ViewBag.CountPosition = listvt.Count;

            return(View());
        }