Exemplo n.º 1
0
        public JsonResult DeleteCarPart(int Id)
        {
            var  dao = new CarPartDAO();
            bool mes = dao.DeleteCarPart(Id);

            return(Json(new { mes = mes }));
        }
Exemplo n.º 2
0
        public JsonResult ChangeStatus(int Id)
        {
            var  dao = new CarPartDAO();
            bool?res = dao.ChangeStatus(Id);

            return(Json(new { res = res }));
        }
Exemplo n.º 3
0
        public JsonResult GetCarPartById(int Id)
        {
            var dao  = new CarPartDAO();
            var data = dao.GetCarPartByID(Id);

            return(Json(new { data = data }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public JsonResult LoadCarPartCategory()
        {
            CarPartDAO dao      = new CarPartDAO();
            var        category = dao.LoadCarPartCategory();

            return(Json(new { category = category }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public JsonResult LoadCarPart(int page, int pageSize)
        {
            CarPartDAO dao      = new CarPartDAO();
            var        data     = dao.LoadCarPart().Skip((page - 1) * pageSize).Take(pageSize);
            var        category = dao.LoadNameCategory(data);
            int        totalRow = data.Count();

            return(Json(new { data = data, category = category, totalRowCarPart = totalRow, }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public JsonResult CreateEditCarPart(string strCarpart)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            CarPart    entity = serializer.Deserialize <CarPart>(strCarpart);
            CarPartDAO dao    = new CarPartDAO();

            entity.MetaTitle   = Common.convertToUnSign.convert(entity.Name);
            entity.Description = (String)System.Net.WebUtility.HtmlDecode(entity.Description);
            int res = dao.CreateEditCarPart(entity, (string)Session[Common.CommonConstants.USER_NAME]);

            return(Json(new { res = res }));
        }
        public ActionResult ViewCarPart(int id)
        {
            ViewBag.CarPartCategory = new CarPartCategoryDAO().LoadCarPartCategory();
            CarPart carpart = new CarPartDAO().GetCarPartByID(id);

            ViewBag.Title           = carpart.SeoTitle;
            ViewBag.MetaKeywords    = carpart.MetaKeywords;
            ViewBag.MetaDescription = carpart.MetaDescriptions;
            ViewBag.CategoryName    = new CarPartCategoryDAO().GetDetailByID((int)carpart.CategoryID);
            ViewBag.OriginName      = new OriginDAO().GetOriginByID(carpart.OriginID);
            ViewBag.ManuName        = new ManufacturerDAO().GetManufacturerByID(carpart.ManufacturerID);
            return(View(carpart));
        }
        public ActionResult ViewListCarPart(int id, int page = 1, int pageSize = 8, int nsx = 0, int xuatxu = 0)
        {
            ViewBag.CarPartCategory     = new CarPartCategoryDAO().LoadCarPartCategory();
            ViewBag.ManufacturerCarPart = new ManufacturerDAO().LoadListManufacturer().Where(x => x.Status == true);
            ViewBag.OriginCarPart       = new OriginDAO().LoadListOrigin().Where(x => x.Status == true && x.Type == 0);

            ViewBag.ManuID   = nsx;
            ViewBag.OriginID = xuatxu;

            var entity = new CarPartCategoryDAO().GetDetailByID(id);

            ViewBag.Title           = entity.SeoTitle;
            ViewBag.MetaKeywords    = entity.MetaKeywords;
            ViewBag.MetaDescription = entity.MetaDescriptions;

            ViewBag.CategoryCurrent = entity;

            IEnumerable <CarPart> carpart = new CarPartDAO().LoadCarPart();
            int totalRecord = new CarPartDAO().LoadCarPart().Count();

            if (id != 20)
            {
                carpart     = new CarPartDAO().GetCarPartByCategoryID(carpart, id);
                totalRecord = carpart.Count();
            }
            if (xuatxu != 0)
            {
                carpart     = carpart.Where(x => x.OriginID == xuatxu);
                totalRecord = carpart.Count();
            }
            if (nsx != 0)
            {
                carpart     = carpart.Where(x => x.ManufacturerID == nsx);
                totalRecord = carpart.Count();
            }
            carpart = carpart.Skip((page - 1) * pageSize).Take(pageSize);

            ViewBag.totalRecord = totalRecord;
            ViewBag.Page        = page;
            int maxPage   = 5;
            int totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)) + 1;

            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Next      = page + 1;
            ViewBag.Last      = totalPage;
            ViewBag.Prev      = page - 1 > 0 ? page - 1 : 1;

            return(View(carpart));
        }
        public ActionResult AddItem(long carpartId, int quantity)
        {
            var carpart = new CarPartDAO().GetCarPartByID((int)carpartId);
            var cart    = Session[CartSession];

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.CarPart.ID == carpartId))
                {
                    foreach (var item in list)
                    {
                        if (item.CarPart.ID == carpartId)
                        {
                            item.Quantity += quantity;
                        }
                    }
                }
                else
                {
                    //Tạo mới cart item
                    var item = new CartItem();
                    item.CarPart  = carpart;
                    item.Quantity = quantity;
                    list.Add(item);

                    //Gán vào session
                    Session[CartSession] = list;
                }
            }
            else
            {
                //Tạo mới cart item
                var item = new CartItem();
                item.CarPart  = carpart;
                item.Quantity = quantity;
                var list = new List <CartItem>();
                list.Add(item);
                //Gán vào session
                Session[CartSession] = list;
            }

            ViewBag.CarPartCategory = new CarPartCategoryDAO().LoadCarPartCategory();
            ViewBag.Title           = "Giỏ Hàng | Buy And Sell Cars";

            return(RedirectToAction("Index"));
        }