Пример #1
0
        public IHttpActionResult PutNhanVienGiaoHang(int id, NhanVienGiaoHang nhanVienGiaoHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != nhanVienGiaoHang.MaNV)
            {
                return(BadRequest());
            }

            db.Entry(nhanVienGiaoHang).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NhanVienGiaoHangExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Edit(NhanVienGiaoHang nhanVienGiaoHang)
        {
            HttpResponseMessage response = client.PutAsJsonAsync(url + @"nhanviengiaohang/" + nhanVienGiaoHang.MaNV, nhanVienGiaoHang).Result;

            response.EnsureSuccessStatusCode();

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public IHttpActionResult GetNhanVienGiaoHang(int id)
        {
            NhanVienGiaoHang nhanVienGiaoHang = db.NhanVienGiaoHangs.Find(id);

            if (nhanVienGiaoHang == null)
            {
                return(NotFound());
            }

            return(Ok(nhanVienGiaoHang));
        }
        public ActionResult Create(NhanVienGiaoHang nhanVienGiaoHang)
        {
            HttpResponseMessage response = client.PostAsJsonAsync(url + @"nhanviengiaohang/", nhanVienGiaoHang).Result;

            response.EnsureSuccessStatusCode();
            if (response.IsSuccessStatusCode)
            {
                ViewBag.Detail = "Sucess";
            }
            return(RedirectToAction("Index"));
        }
        // GET: NhanVienGiaoHang/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            NhanVienGiaoHang    nhanVienGiaoHang = null;
            HttpResponseMessage response         = await client.GetAsync(url + @"nhanviengiaohang/" + id);

            if (response.IsSuccessStatusCode)
            {
                nhanVienGiaoHang = await response.Content.ReadAsAsync <NhanVienGiaoHang>();
            }
            return(View(nhanVienGiaoHang));
        }
Пример #6
0
        public IHttpActionResult PostNhanVienGiaoHang(NhanVienGiaoHang nhanVienGiaoHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NhanVienGiaoHangs.Add(nhanVienGiaoHang);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = nhanVienGiaoHang.MaNV }, nhanVienGiaoHang));
        }
Пример #7
0
        public IHttpActionResult DeleteNhanVienGiaoHang(int id)
        {
            NhanVienGiaoHang nhanVienGiaoHang = db.NhanVienGiaoHangs.Find(id);

            if (nhanVienGiaoHang == null)
            {
                return(NotFound());
            }

            db.NhanVienGiaoHangs.Remove(nhanVienGiaoHang);
            db.SaveChanges();

            return(Ok(nhanVienGiaoHang));
        }
        // GET: NhanVienGiaoHang/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            NhanVienGiaoHang    nhanVienGiaoHang = null;
            HttpResponseMessage response         = await client.GetAsync(url + @"nhanviengiaohang/" + id);

            if (response.IsSuccessStatusCode)
            {
                ViewBag.accept   = false;
                nhanVienGiaoHang = await response.Content.ReadAsAsync <NhanVienGiaoHang>();

                response = await client.GetAsync(url + @"lichsunvgh/");

                List <LichSuNVGH> ls = LichSuNVGHController.getAllLichSuGD(response).Where(n => n.MaNV == id).ToList();
                ViewBag.lsnvgh = ls;
            }
            return(View(nhanVienGiaoHang));
        }
        // GET: chiTietDonHAng/Details
        public async Task <ActionResult> Details(int?id, int?MaKH)
        {
            HttpResponseMessage response = await client.GetAsync(url + @"chitietdonhang/" + id);

            if (response.IsSuccessStatusCode)
            {
                var responseData = response.Content.ReadAsStringAsync().Result;
                var settings     = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };
                var chiTietDonHangs      = JsonConvert.DeserializeObject <List <ChiTietDonHang> >(responseData, settings);
                List <ChiTietDonHang> ds = chiTietDonHangs.ToList();
                // id mdh
                ViewBag.MDH = id;

                // Get total price
                ViewBag.total = getTotal(ds);

                // Get don dat hang
                HttpResponseMessage responseMessage = await client.GetAsync(url + @"dondathang/");

                List <DonDatHang> donDatHangs = getAllOrder(responseMessage);
                DonDatHang        ddh         = donDatHangs.SingleOrDefault(n => n.MaDonHang == id);
                ViewBag.ngaydat   = ddh.NgayDat;
                ViewBag.tinhtrang = ddh.TinhTrangDonHang;
                ViewBag.tg        = ddh.TgGiao;

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

                List <DoAn>   listda = DoAnController.getAllDoAn(responseMessage);
                List <string> dsTen  = new List <string>();
                foreach (ChiTietDonHang ctdh in ds)
                {
                    string name = listda.Where(n => n.MaDA == ctdh.MaDA).SingleOrDefault().TenDA;
                    dsTen.Add(name);
                }
                //DoAn doAn = listda.Where(n => n.MaDA == );
                ViewBag.nameDa = dsTen;

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

                List <KhachHang> list      = KhachHangController.getAllCustomer(responseMessage);
                KhachHang        khachHang = list.Where(n => n.MaKH == MaKH).SingleOrDefault();
                ViewBag.name = khachHang.HoTenKH;
                ViewBag.id   = khachHang.MaKH;
                ViewBag.dtkh = khachHang.DienThoaiKH;

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

                List <ViTriGiaoHang> listVt = ViTriGiaoHangController.getAllPosition(responseMessage);
                ViTriGiaoHang        viTri  = listVt.Where(n => n.MaVT == ddh.MaVT).SingleOrDefault();
                ViewBag.vitri = viTri.TenVT;

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

                List <NhanVienGiaoHang> listnv   = NhanVienGiaoHangController.getAllNhanVienGH(responseMessage);
                NhanVienGiaoHang        nhanvien = listnv.Where(n => n.MaNV == ddh.MaNV).SingleOrDefault();
                ViewBag.namenv = nhanvien.HoTenNV;
                ViewBag.idnv   = nhanvien.MaNV;
                ViewBag.dtnv   = nhanvien.DienThoaiNV;

                ////get DoAn
                //responseMessage = await client.GetAsync(url + @"doan/");
                //List<DoAn> listda = HTFood.Controllers.DoAnController.getAllDoAn(responseMessage);
                //DoAn doAn = listda.Where(n => n.MaDA == MaDA).SingleOrDefault();
                //ViewBag.nameDa = doAn.TenDA;

                return(View(chiTietDonHangs.ToList()));
            }
            return(View());
        }