Beispiel #1
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());
        }
Beispiel #2
0
        // GET: KhachHang/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            // Init variable
            KhachHang           khachHangs = null;
            HttpResponseMessage response   = await client.GetAsync(url + @"khachhang/" + id);

            if (response.IsSuccessStatusCode)
            {
                //dong hoac mo data table
                ViewBag.accept = false;
                khachHangs     = await response.Content.ReadAsAsync <KhachHang>();

                //List<KhachHang> kh = getAllCustomer(response);
                //KhachHang khs = kh.SingleOrDefault(n => n.MaKH == id);
                //ViewBag.tenkh = khs.HoTenKH;

                // Call api
                HttpResponseMessage responseMessage = await client.GetAsync(url + @"vitien/");

                // Get all data from the ViTien table
                List <ViTien> viTiens = ViTienController.getAllViTien(responseMessage);
                // Check data with id customer
                viTiens        = viTiens.Where(n => n.MaKH == id).ToList();
                ViewBag.vitien = viTiens;
                // Get all data from the LichSuGD table
                responseMessage = await client.GetAsync(url + @"lichsugd/");

                List <LichSuGD> lichSuGDs = new List <LichSuGD>();
                foreach (ViTien vt in viTiens)
                {
                    // Check data with id ViTien
                    List <LichSuGD> temp = LichSuGDController.getAllLichSuGD(responseMessage).Where(n => n.MaViTien == vt.MaViTien).ToList();
                    // Is exist
                    if (temp != null)
                    {
                        // Save data
                        foreach (LichSuGD lichSuGD in temp)
                        {
                            lichSuGDs.Add(lichSuGD);
                        }
                    }
                }
                // assign values to variables ViewBag.lsgd
                ViewBag.lsgd = lichSuGDs.ToList();
                //dsyt
                responseMessage = await client.GetAsync(url + @"dsyeuthich/");

                List <DSYeuThich> dSYeuThiches = getAllDSYT(responseMessage);
                // Check data with id customer
                dSYeuThiches = dSYeuThiches.Where(n => n.MaKH == id).ToList();
                ViewBag.DSYT = dSYeuThiches;
                //getCH
                responseMessage = await client.GetAsync(url + @"cuahang/");

                List <Cuahang> listch = CuahangController.getAllCuaHang(responseMessage);
                List <string>  dsTen  = new List <string>();
                foreach (DSYeuThich dsyt in dSYeuThiches)
                {
                    string namech = listch.Where(n => n.MaCH == dsyt.MaCH).SingleOrDefault().TenCH;
                    dsTen.Add(namech);
                }
                ViewBag.tench = dsTen;
            }

            // Return
            return(View(khachHangs));
        }