示例#1
0
        public IHttpActionResult PutViTriGiaoHang(int id, ViTriGiaoHang viTriGiaoHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != viTriGiaoHang.MaVT)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Edit(ViTriGiaoHang viTriGiaoHangs)
        {
            HttpResponseMessage response = client.PutAsJsonAsync(url + @"vitrigiaohang/" + viTriGiaoHangs.MaVT, viTriGiaoHangs).Result;

            response.EnsureSuccessStatusCode();

            return(RedirectToAction("Index"));
        }
示例#3
0
        public IHttpActionResult GetViTriGiaoHang(int id)
        {
            ViTriGiaoHang viTriGiaoHang = db.ViTriGiaoHangs.Find(id);

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

            return(Ok(viTriGiaoHang));
        }
        public ActionResult Create(ViTriGiaoHang viTriGiaoHangs)
        {
            HttpResponseMessage response = client.PostAsJsonAsync(url + @"vitrigiaohang/", viTriGiaoHangs).Result;

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

            if (response.IsSuccessStatusCode)
            {
                viTriGiaoHangs = await response.Content.ReadAsAsync <ViTriGiaoHang>();
            }
            return(View(viTriGiaoHangs));
        }
示例#6
0
        public IHttpActionResult PostViTriGiaoHang(ViTriGiaoHang viTriGiaoHang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ViTriGiaoHangs.Add(viTriGiaoHang);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = viTriGiaoHang.MaVT }, viTriGiaoHang));
        }
示例#7
0
        public IHttpActionResult DeleteViTriGiaoHang(int id)
        {
            ViTriGiaoHang viTriGiaoHang = db.ViTriGiaoHangs.Find(id);

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

            db.ViTriGiaoHangs.Remove(viTriGiaoHang);
            db.SaveChanges();

            return(Ok(viTriGiaoHang));
        }
        // 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());
        }