Beispiel #1
0
        public void initAdminClient()
        {
            ClientDao    dao  = new ClientDao();
            ClientEntity temp = dao.getClientByUsername("admin");

            if (temp != null)
            {
                dao.DeleteClient("admin");
            }


            ClientEntity  client        = new ClientEntity();
            RoleDao       roleDao       = new RoleDao();
            DepartmentDao departmentDao = new DepartmentDao();

            client.Username = "******";
            client.Password = "******";
            client.RealName = "yangtf";

            client.Role       = roleDao.getByName("superadmin");
            client.Department = departmentDao.getByName("6");
            client.encryptPassword();

            IList <CatalogEntity> catalogs = new CatalogDao().getAll();

            client.Catalogs = catalogs;


            dao.save(client);
        }
Beispiel #2
0
        public CatalogManager(CatalogDao catalogDao)
        {
            _dao = catalogDao;

            _pages    = new List <CatalogPage>();
            _featured = new List <CatalogFeatured>();
            _bots     = new List <CatalogBots>();
        }
Beispiel #3
0
        public void DeleteClientsForCatalog(string catalog_name, string[] usernames)
        {
            CatalogEntity catalog = new CatalogDao().get(catalog_name);

            if (catalog != null)
            {
                DeleteClientsForCatalog(catalog, usernames);
            }
        }
Beispiel #4
0
        public JsonResult DeleteCatalog(int id)
        {
            var check = new CatalogDao().DeleteCatalog(id);

            return(Json(new
            {
                status = check
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddItem(int id, int quantity = 1)
        {
            var catalog = new CatalogDao().findById(id);
            var cart    = Session[CommonConstant.CART_SESSION];

            if (quantity > 10)
            {
                quantity = 10;
            }
            if (quantity < 1)
            {
                quantity = 1;
            }
            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.catalog.id == id))
                {
                    foreach (var item in list)
                    {
                        if (item.catalog.id == id && (item.quantity + quantity) <= 10)
                        {
                            item.quantity += quantity;
                        }
                    }
                }
                else
                {
                    // tao moi doi tuong cart item
                    var item = new CartItem
                    {
                        catalog  = catalog,
                        quantity = quantity
                    };
                    list.Add(item);
                }
                // gan vao session
                Session[CommonConstant.CART_SESSION] = list;
            }
            else
            {
                // tao moi doi tuong cart item
                var item = new CartItem
                {
                    catalog  = catalog,
                    quantity = quantity
                };
                var list = new List <CartItem>
                {
                    item
                };
                // gan vao session
                Session[CommonConstant.CART_SESSION] = list;
            }
            return(RedirectToAction("index"));
        }
Beispiel #6
0
        public JsonResult GetAllType()
        {
            var catalogDao = new CatalogDao();
            var types      = catalogDao.GetCatalogType();

            return(Json(new
            {
                types = types.Items
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        public JsonResult GetAllBrand()
        {
            var catalogDao = new CatalogDao();
            var brands     = catalogDao.GetCatalogBrand();

            return(Json(new
            {
                brands = brands.Items
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        public JsonResult LoadDetail(int id)
        {
            var catalogDao = new CatalogDao();
            var catalog    = catalogDao.GetCatalogById(id);

            return(Json(new
            {
                data = catalog
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        public Dictionary <Product, int> GetProducts()
        {
            CatalogDao catalogDao         = new CatalogDao();
            Dictionary <Product, int> res = new Dictionary <Product, int>();

            foreach (var id in keyValuePairs.Keys)
            {
                res[catalogDao.GetProduct(id)] = keyValuePairs[id];
            }
            return(res);
        }
Beispiel #10
0
        private void initCatalog()
        {
            string[]        catalogNames = { "调研文章", "审批", "申请" };
            CatalogEntity[] catalogs     = new CatalogEntity[3];
            for (int index = 0; index < catalogNames.Length; index++)
            {
                catalogs[index] = new CatalogEntity(catalogNames[index]);
            }
            CatalogDao dao = new CatalogDao();

            dao.save(catalogs);
        }
Beispiel #11
0
        public JsonResult GetAll(string name, int idbrand, int idtype, int status, int page, int pageSize)
        {
            var catalogDao = new CatalogDao();
            var result     = catalogDao.GetAll(name, idbrand, idtype, status, page, pageSize);
            var types      = catalogDao.GetCatalogType();

            return(Json(new
            {
                totalRow = result.TotalRecord,
                data = result.Items,
                types = types.Items
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        public ActionResult Edit(CatalogBrand entity)
        {
            var dao   = new CatalogDao();
            var check = dao.UpdateCatalogBrand(entity);

            if (check == 1)
            {
                TempData["Message"] = "Cập nhật thành công";
                return(RedirectToAction("index"));
            }
            ModelState.AddModelError("", "Cập nhật thất bại");
            return(View());
        }
Beispiel #13
0
        public ListCatalogBrand()
        {
            var dao = new CatalogDao();

            listBrand = new List <SelectListItem>();
            foreach (CatalogBrand cb in dao.getAllBrand())
            {
                listBrand.Add(new SelectListItem
                {
                    Value = cb.id.ToString(),
                    Text  = cb.brand
                });
            }
        }
Beispiel #14
0
        public void TestCasCadeCatalog()
        {
            CatalogEntity catalog = new CatalogEntity("test cata for cascade");
            CatalogDao    dao     = new CatalogDao();

            dao.save(catalog);

            ArticleEntity article = new ArticleEntity();

            article.Author  = new ClientDao().getClientByUsername("admin");
            article.Catalog = new CatalogDao().get(catalog.CatalogName);
            article.Title   = "test title";
            article.Content = "test content";

            ArticleDao articleDao = new ArticleDao();

            articleDao.save(article);
        }
Beispiel #15
0
        public JsonResult Delete(int id)
        {
            var check = new CatalogDao().DeleteBrand(id);

            if (check == 1)
            {
                return(Json(new
                {
                    message = "success",
                    status = true
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                message = "falied",
                status = false
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #16
0
        public JsonResult SaveCatalog(int id, int type, string model)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var catalogDao = new CatalogDao();
            var check      = false;

            if (type == 1)
            {
                var catalogDTO = serializer.Deserialize <MobileDTO>(model);
                check = catalogDao.SaveMobile(id, catalogDTO);
            }
            else if (type == 2)
            {
                var catalogDTO = serializer.Deserialize <LaptopDTO>(model);
                check = catalogDao.SaveLaptop(id, catalogDTO);
            }
            return(Json(new
            {
                status = check
            }));
        }
Beispiel #17
0
 public ActionResult AddNewBrand(CatalogBrand entity)
 {
     if (ModelState.IsValid)
     {
         var catalogDao = new CatalogDao();
         try
         {
             int check = catalogDao.AddNewBrand(entity);
             if (check == 1)
             {
                 TempData["Message"] = "Thêm thương hiệu thành công";
                 return(RedirectToAction("index"));
             }
             ModelState.AddModelError("", "Đã tồn tại tên thương hiệu");
             return(View("AddNewBrand"));
         }
         catch (Exception)
         {
             ModelState.AddModelError("", "Lỗi!");
             return(View("AddNewBrand"));
         }
     }
     return(View("AddNewBrand"));
 }
Beispiel #18
0
 public void TestGetCatalog()
 {
     IList <CatalogEntity> catalogs = new CatalogDao().getCatalogsForMainPage();
 }
Beispiel #19
0
        public void AuthorizeCatalogToClients(string catalog_name, string[] usernames)
        {
            CatalogEntity catalog = new CatalogDao().get(catalog_name);

            this.AuthorizeCatalogToClients(catalog, usernames);
        }
Beispiel #20
0
        public ActionResult Edit(int id)
        {
            var model = new CatalogDao().findCatalogBrandById(id);

            return(View(model));
        }
Beispiel #21
0
        // GET: Admin/Brand
        public ActionResult Index()
        {
            var brand = new CatalogDao().getAllBrand();

            return(View(brand));
        }
Beispiel #22
0
 public void LoadGird()
 {
     gvCat.DataSource = CatalogDao.GetList(_ConfigItem);
 }
Beispiel #23
0
 public CatalogService()
 {
     dao = new CatalogDao();
 }
Beispiel #24
0
        public PartialViewResult Footer()
        {
            var model = new CatalogDao().getListCatalog();

            return(PartialView(model));
        }
Beispiel #25
0
        public PartialViewResult ProductCategory()
        {
            var model = new CatalogDao().getListCatalog();

            return(PartialView(model));
        }
Beispiel #26
0
 private void LoadCatalog()
 {
     repositoryItemLookUpEdit1.DataSource = CatalogDao.GetList(_ConfigItem);
 }
Beispiel #27
0
 public CatalogBusiness(MardisContext mardisContext)
 {
     _catalogDao = new CatalogDao(mardisContext);
 }
Beispiel #28
0
 public void TestGetCatalogsByNames()
 {
     string[]              names = { "申请", "调研文章" };
     CatalogDao            dao   = new CatalogDao();
     IList <CatalogEntity> list  = dao.getCatalogsByNames(names);
 }