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); }
public CatalogManager(CatalogDao catalogDao) { _dao = catalogDao; _pages = new List <CatalogPage>(); _featured = new List <CatalogFeatured>(); _bots = new List <CatalogBots>(); }
public void DeleteClientsForCatalog(string catalog_name, string[] usernames) { CatalogEntity catalog = new CatalogDao().get(catalog_name); if (catalog != null) { DeleteClientsForCatalog(catalog, usernames); } }
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")); }
public JsonResult GetAllType() { var catalogDao = new CatalogDao(); var types = catalogDao.GetCatalogType(); return(Json(new { types = types.Items }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllBrand() { var catalogDao = new CatalogDao(); var brands = catalogDao.GetCatalogBrand(); return(Json(new { brands = brands.Items }, JsonRequestBehavior.AllowGet)); }
public JsonResult LoadDetail(int id) { var catalogDao = new CatalogDao(); var catalog = catalogDao.GetCatalogById(id); return(Json(new { data = catalog }, JsonRequestBehavior.AllowGet)); }
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); }
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); }
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)); }
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()); }
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 }); } }
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); }
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)); }
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 })); }
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")); }
public void TestGetCatalog() { IList <CatalogEntity> catalogs = new CatalogDao().getCatalogsForMainPage(); }
public void AuthorizeCatalogToClients(string catalog_name, string[] usernames) { CatalogEntity catalog = new CatalogDao().get(catalog_name); this.AuthorizeCatalogToClients(catalog, usernames); }
public ActionResult Edit(int id) { var model = new CatalogDao().findCatalogBrandById(id); return(View(model)); }
// GET: Admin/Brand public ActionResult Index() { var brand = new CatalogDao().getAllBrand(); return(View(brand)); }
public void LoadGird() { gvCat.DataSource = CatalogDao.GetList(_ConfigItem); }
public CatalogService() { dao = new CatalogDao(); }
public PartialViewResult Footer() { var model = new CatalogDao().getListCatalog(); return(PartialView(model)); }
public PartialViewResult ProductCategory() { var model = new CatalogDao().getListCatalog(); return(PartialView(model)); }
private void LoadCatalog() { repositoryItemLookUpEdit1.DataSource = CatalogDao.GetList(_ConfigItem); }
public CatalogBusiness(MardisContext mardisContext) { _catalogDao = new CatalogDao(mardisContext); }
public void TestGetCatalogsByNames() { string[] names = { "申请", "调研文章" }; CatalogDao dao = new CatalogDao(); IList <CatalogEntity> list = dao.getCatalogsByNames(names); }