Ejemplo n.º 1
0
        public IActionResult SingleProduct(string metatitle)
        {
            getSession();
            Sanpham     tmp = _Sanpham.GetSanPhamByMetaTitle(metatitle);
            Loaisanpham a   = _Sanpham.GetLoaiSanPham((int)tmp.IdLoaiSanPham);

            ViewBag.CateTitle = a.metatitle;
            ViewBag.MetaTitle = metatitle;
            var Id = tmp.Id;

            ViewBag.SanPham        = _Sanpham.GetSanPham(Id);
            ViewBag.ChiTietSanPham = _Sanpham.GetChiTietSanPham(Id);
            ViewBag.Loai           = _Sanpham.GetLoaiSanPham(Id);

            ViewBag.ss = HttpContext.Session.GetInt32("Id");
            ViewBag.SanPhamCungLoai    = _Sanpham.GetSanPhamsByIdLoaiSanPham(_Sanpham.GetLoaiSanPham(Id).Id);
            ViewBag.ListChiTietSanPham = _Sanpham.GetChiTietSanPhams;
            //ViewBag.ListSanPham = _Sanpham.GetSanPhams;

            Chitietdonhang dh = new Chitietdonhang();

            dh.Id        = HttpContext.Session.GetInt32("Id");
            dh.IdSanPham = Id;
            dh.SoLuong   = 0;
            dh.Gia       = 0;

            return(View(dh));
        }
Ejemplo n.º 2
0
        public IActionResult Index(string metatitle, int Page)
        {
            getSession();
            ViewBag.ListChiTietSanPham = _Sanpham.GetChiTietSanPhams;
            ViewBag.ListLoaiSanPham    = _Sanpham.GetLoaiSanPhams;
            ViewBag.Cate = true;
            Loaisanpham res = _Sanpham.getLoaiSanPhamByMetatitle(metatitle);
            int         Id  = res.Id;

            if (_Sanpham.GetSanPhamsByIdLoaiSanPham(Id).Count() % 8 > 0)
            {
                ViewBag.AllPage = _Sanpham.GetSanPhamsByIdLoaiSanPham(Id).Count() / 8 + 1;
            }
            else
            {
                ViewBag.AllPage = _Sanpham.GetSanPhamsByIdLoaiSanPham(Id).Count() / 8;
            }
            ViewBag.IdCate    = Id;
            ViewBag.metatitle = res.metatitle;

            if (Page < 1)
            {
                ViewBag.CurrentPage = 1;
            }
            else if (Page > ViewBag.AllPage)
            {
                ViewBag.CurrentPage = ViewBag.AllPage;
            }
            else
            {
                ViewBag.CurrentPage = Page;
            }

            return(View(_Sanpham.GetSanPhamsByIdLoaiSanPham(Id)));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Loaisanpham> > PostLoaisanpham(Loaisanpham loaisanpham)
        {
            _context.Loaisanphams.Add(loaisanpham);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLoaisanpham", new { id = loaisanpham.Id }, loaisanpham));
        }
Ejemplo n.º 4
0
        // Loại sản phẩm
        public Loaisanpham GetLoaiSanPham(int Id)
        {
            Sanpham     a   = GetSanPham(Id);
            Loaisanpham res = db.Loaisanpham.Find(a.IdLoaiSanPham);

            return(res);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PutLoaisanpham(int id, Loaisanpham loaisanpham)
        {
            if (id != loaisanpham.Id)
            {
                return(BadRequest());
            }

            _context.Entry(loaisanpham).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoaisanphamExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 6
0
        public void UpdateMetatitle(int?Id, string metatitle)
        {
            Loaisanpham res = db.Loaisanpham.Find(Id);

            res.metatitle = metatitle;
            db.SaveChanges();
        }
Ejemplo n.º 7
0
        public void Update(Loaisanpham _LoaiSanPham)
        {
            Loaisanpham res = db.Loaisanpham.Find(_LoaiSanPham.Id);

            res.Ten = _LoaiSanPham.Ten;
            db.SaveChanges();
        }
Ejemplo n.º 8
0
        public void Remove(int?Id)
        {
            Loaisanpham res = db.Loaisanpham.Find(Id);

            db.Loaisanpham.Remove(res);
            db.SaveChanges();
        }
Ejemplo n.º 9
0
        public void removeLoaiSanPham(int Id)
        {
            Loaisanpham res = db.Loaisanpham.Find(Id);

            db.Loaisanpham.Remove(res);
            db.SaveChanges();
        }
        public ActionResult DeleteConfirmed(string id)
        {
            Loaisanpham loaisanpham = db.Loaisanphams.Find(id);

            db.Loaisanphams.Remove(loaisanpham);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "MALOAI,TENLOAI")] Loaisanpham loaisanpham)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loaisanpham).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(loaisanpham));
 }
Ejemplo n.º 12
0
 public IActionResult Create(Loaisanpham _LoaiSanPham)
 {
     if (ModelState.IsValid)
     {
         _LoaiSanPham.metatitle = FriendlyURLHelper.GetFriendlyTitle(_LoaiSanPham.Ten);
         ILoaiSanPham.Add(_LoaiSanPham);
         return(RedirectToAction("Index"));
     }
     return(View(_LoaiSanPham));
 }
        public ActionResult Create([Bind(Include = "MALOAI,TENLOAI")] Loaisanpham loaisanpham)
        {
            if (ModelState.IsValid)
            {
                db.Loaisanphams.Add(loaisanpham);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(loaisanpham));
        }
Ejemplo n.º 14
0
 public IActionResult Delete(int?Id)
 {
     if (Id == null)
     {
         return(NotFound());
     }
     else
     {
         Loaisanpham model = ILoaiSanPham.GetLoaisanpham(Id);
         return(View(model));
     }
 }
Ejemplo n.º 15
0
 public IActionResult Edit(int?Id)
 {
     if (Id == null)
     {
         return(NotFound());
     }
     else
     {
         Loaisanpham res = ILoaiSanPham.GetLoaisanpham(Id);
         return(View(res));
     }
 }
        // GET: Loaisanpham/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Loaisanpham loaisanpham = db.Loaisanphams.Find(id);

            if (loaisanpham == null)
            {
                return(HttpNotFound());
            }
            return(View(loaisanpham));
        }
Ejemplo n.º 17
0
        public Loaisanpham GetLoaisanpham(int?Id)
        {
            Loaisanpham res = db.Loaisanpham.Find(Id);

            return(res);
        }
Ejemplo n.º 18
0
 public void updateLoaiSanPham(Loaisanpham _Loaisanpham)
 {
     db.Loaisanpham.Update(_Loaisanpham);
     db.SaveChanges();
 }
Ejemplo n.º 19
0
 // Thêm - sửa - xóa
 public void addLoaiSanPham(Loaisanpham _Loaisanpham)
 {
     db.Loaisanpham.Add(_Loaisanpham);
     db.SaveChanges();
 }
Ejemplo n.º 20
0
        public Loaisanpham getLoaiSanPhamByMetatitle(string metatitle)
        {
            Loaisanpham a = db.Loaisanpham.Where(p => p.metatitle == metatitle).SingleOrDefault();

            return(a);
        }
Ejemplo n.º 21
0
 public IActionResult Edit(Loaisanpham _LoaiSanPham)
 {
     _LoaiSanPham.metatitle = FriendlyURLHelper.GetFriendlyTitle(_LoaiSanPham.Ten);
     ILoaiSanPham.Update(_LoaiSanPham);
     return(RedirectToAction("Index"));
 }