/// <summary>
        /// This method is used to get all categories
        /// </summary>
        /// <returns></returns>
        List <UI.Entities.CategoryModel> ICategoryBL.GetAllCategories()
        {
            ICategoriesDAL CatDAL = new CategoriesDAL();
            List <UI.Entities.CategoryModel> result = CatDAL.GetCategoryList();

            return(result);
        }
Example #2
0
        public void Update(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL updateProduct = new ProductsDAL();
                updateProduct.UpdateProduct((dtoName as ProductDTO).ProductOldName,
                                            (dtoName as ProductDTO).ProductNewName,
                                            (dtoName as ProductDTO).CategoryName,
                                            (dtoName as ProductDTO).VendorName,
                                            (dtoName as ProductDTO).ProductPrice,
                                            (dtoName as ProductDTO).Quantity,
                                            (dtoName as ProductDTO).StoreName,
                                            (dtoName as ProductDTO).TownName);
                resultMessage = updateProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL updateVendor = new VendorsDAL();
                updateVendor.UpdateVendor((dtoName as VendorDTO).VendorOldName, (dtoName as VendorDTO).VendorName);
                resultMessage = updateVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL updateCategory = new CategoriesDAL();
                updateCategory.UpdateCategory((dtoName as CategoryDTO).CategoryOldName, (dtoName as CategoryDTO).CategoryName);
                resultMessage = updateCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
        public List <CategoryModel> GetCategory(string CategoryCode)
        {
            ICategoriesDAL CatDAL = new CategoriesDAL();
            List <UI.Entities.CategoryModel> result = CatDAL.GetCategory(CategoryCode);

            return(result);
        }
        public List <ContentModel> GetPSCategoryList()
        {
            ICategoriesDAL CatDAL = new CategoriesDAL();
            List <UI.Entities.ContentModel> result = CatDAL.GetPSCategoryList();

            return(result);
        }
Example #5
0
        public List <CategoryDTO> GetCategories()
        {
            CategoriesDAL      getCategories = new CategoriesDAL();
            List <CategoryDTO> allCategories = getCategories.GetAllCategories();

            return(allCategories);
        }
Example #6
0
        public void Delete(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL deleteProduct = new ProductsDAL();
                deleteProduct.DeleteProduct((dtoName as ProductDTO).ProductNewName);
                resultMessage = deleteProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL deleteVendor = new VendorsDAL();
                deleteVendor.DeleteVendor((dtoName as VendorDTO).VendorName);
                resultMessage = deleteVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL deleteCategory = new CategoriesDAL();
                deleteCategory.DeleteCategory((dtoName as CategoryDTO).CategoryName);
                resultMessage = deleteCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
Example #7
0
        public ActionResult Create()
        {
            //data author
            var lstAuthor = new List <SelectListItem>();

            using (AuthorsDAL svAuthors = new AuthorsDAL())
            {
                foreach (var author in svAuthors.GetData())
                {
                    lstAuthor.Add(new SelectListItem
                    {
                        Value = author.AuthorID.ToString(),
                        Text  = author.FirstName + " " + author.LastName
                    });
                }
                ViewBag.Authors = lstAuthor;
            }
            //
            var lstCat = new List <SelectListItem>();

            using (CategoriesDAL svCat = new CategoriesDAL())
            {
                foreach (var cat in svCat.GetData())
                {
                    lstCat.Add(new SelectListItem
                    {
                        Value = cat.CategoryID.ToString(),
                        Text  = cat.CategoryName
                    });
                }
                ViewBag.Categories = lstCat;
            }
            return(View());
        }
        // GET: Categories/Delete/5
        public ActionResult Delete(int id)
        {
            CategoriesDAL categoriesDAL = new CategoriesDAL();
            var           model         = categoriesDAL.GetById(id);

            return(View(model));
        }
Example #9
0
        public ActionResult Add()
        {
            ViewBag.listCategories = new SelectList(CategoriesDAL.GetData(), "ID", "Name");
            ItemsViewModel models = new ItemsViewModel();

            return(PartialView("Add", models));
        }
        // GET: Categories
        public ActionResult Index()
        {
            CategoriesDAL catDal = new CategoriesDAL();
            var           models = catDal.GetAll();

            return(View(models));
        }
Example #11
0
 public ActionResult Search(string txtSearch)
 {
     using (CategoriesDAL cat = new CategoriesDAL())
     {
         var result = cat.Search(txtSearch).ToList();
         return(View("Index", result));
     }
 }
        // GET: Categories/Delete/5
        public ActionResult Delete(int id)
        {
            //memanggil methode delete pada DAL
            CategoriesDAL categoriesDAL = new CategoriesDAL();
            var           model         = categoriesDAL.GetById(id);

            return(View(model));
        }
 public ActionResult Search(string selectKriteria, string txtSearch)
 {
     using (CategoriesDAL svCat = new CategoriesDAL())
     {
         var results = svCat.SearchByKriteria(txtSearch).ToList();
         return(View("Index", results));
     }
 }
 public ActionResult EditCategories(int id)
 {
     using (CategoriesDAL service = new CategoriesDAL())
     {
         var category = service.GetDataByID(id);
         return(View(category));
     }
 }
Example #15
0
        //menampilkan list items yang akan kita tampilkan
        public ActionResult GetItems(int categoryID, int outletId)
        {
            CategoriesViewModel model = CategoriesDAL.GetDataById(categoryID);

            model.ID          = categoryID;
            ViewBag.ListItems = CategoriesDAL.GetItemsData(outletId);
            return(PartialView("ListItems", model));
        }
        public ActionResult Search(string txtSearch)
        {
            using (CategoriesDAL svBooks = new CategoriesDAL())
            {
                var results = svBooks.Search(txtSearch).ToList();

                return(View("ViewAllCategories", results));
            }
        }
Example #17
0
        // GET: Categories
        public ActionResult Index()
        {
            List <CategoriesViewModel> model = CategoriesDAL.GetData();

            // karena kita mau menampilkan list category berdasarkan outlet iD maka kita membuat ViewBag untuk outlet ID
            // jadi prosesnya : kita menginstansiasi select list baru dari method GetData pada OUtletDAL yang nanti kita ambil nilai ID dan Name nya
            ViewBag.ListOutlet = new SelectList(OutletDAL.GetData(), "ID", "OutletName");
            return(View(model));
        }
Example #18
0
        public ReturnResult Delete(int id)
        {
            CommonAPI commonApi = new CommonAPI();

            commonApi.getHeaderValues(Request.Headers, out connectionString, out userAccount, out roleId, out companyCode, out DBProviderName);
            CategoriesDAL categroyDAL  = new CategoriesDAL(connectionString, userAccount, roleId, DBProviderName, companyCode);
            ReturnResult  returnResult = categroyDAL.DeleteCategory(id);

            return(returnResult);
        }
Example #19
0
        public ReturnResult Post([FromBody] Category objCategory)
        {
            CommonAPI commonApi = new CommonAPI();

            commonApi.getHeaderValues(Request.Headers, out connectionString, out userAccount, out roleId, out companyCode, out DBProviderName);
            CategoriesDAL categroyDAL  = new CategoriesDAL(connectionString, userAccount, roleId, DBProviderName, companyCode);
            ReturnResult  returnResult = categroyDAL.SaveCategory(objCategory);

            return(returnResult);
        }
Example #20
0
        public Category Get(int id)
        {
            CommonAPI commonApi = new CommonAPI();

            commonApi.getHeaderValues(Request.Headers, out connectionString, out userAccount, out roleId, out companyCode, out DBProviderName);
            CategoriesDAL categroyDAL = new CategoriesDAL(connectionString, userAccount, roleId, DBProviderName, companyCode);
            var           category    = categroyDAL.GetCategoryById(id);

            return(category);
        }
Example #21
0
        public IEnumerable <Category> Get()
        {
            CommonAPI commonApi = new CommonAPI();

            commonApi.getHeaderValues(Request.Headers, out connectionString, out userAccount, out roleId, out companyCode, out DBProviderName);
            CategoriesDAL categroyDAL = new CategoriesDAL(connectionString, userAccount, roleId, DBProviderName, companyCode);
            var           categories  = categroyDAL.GetCategories();

            return(categories);
        }
        private void loadCategoriesFromDb()
        {
            CategoriesDAL cdal         = new CategoriesDAL();
            DataTable     categoriesDt = new DataTable();

            categoriesDt              = cdal.Select();
            cmbCategory.DataSource    = categoriesDt;
            cmbCategory.DisplayMember = "title";
            cmbCategory.ValueMember   = "title";
        }
 public ActionResult Edit(int id)
 {
     CategoriesDAL c = new CategoriesDAL();
     CategoryDTO dto = new CategoryDTO();
     dto = c.GetCategoryByID(id);
     CategoryModel model = new CategoryModel();
     model.id_categ = dto.id_categ;
     model.categ_name = dto.categ_name;
     return View(model);
 }
Example #24
0
        public ActionResult Delete(int Id)
        {
            //list Category
            ViewBag.listCategories = new SelectList(CategoriesDAL.GetData(), "ID", "Name");
            //list Inventory
            ViewBag.listInventory = new SelectList(ItemsIventoryDAL.GetData(), "ID", "VariantName");

            ListItemViewModel model = ItemsDAL.GetDataById(Id);

            return(PartialView("Delete", model));
        }
Example #25
0
        // GET: Items
        public ActionResult Index()
        {
            //list Category
            ViewBag.listCategories = new SelectList(CategoriesDAL.GetData(), "ID", "Name");
            //list Inventory
            ViewBag.listInventory = new SelectList(ItemsIventoryDAL.GetData(), "ID", "VariantName");

            List <ListItemViewModel> models = ItemDAL.GetData();

            return(View(models));
        }
Example #26
0
        public void Insert(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL newProduct = new ProductsDAL();
                if (newProduct.IsProductNameExistInDb((dtoName as ProductDTO).ProductNewName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Product");
                }
                else
                {
                    newProduct.InsertNewProduct((dtoName as ProductDTO).ProductNewName,
                                                (dtoName as ProductDTO).CategoryName,
                                                (dtoName as ProductDTO).VendorName,
                                                (dtoName as ProductDTO).ProductPrice,
                                                (dtoName as ProductDTO).Quantity,
                                                (dtoName as ProductDTO).StoreName,
                                                (dtoName as ProductDTO).TownName);
                    resultMessage = newProduct.GetCRUDResult();
                }
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL newVendor = new VendorsDAL();
                if (newVendor.IsVendorNameExistInDb((dtoName as VendorDTO).VendorName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Vendor");
                }
                else
                {
                    newVendor.InsertNewVendor((dtoName as VendorDTO).VendorName);
                    resultMessage = newVendor.GetCRUDResult();
                }
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL newCategory = new CategoriesDAL();
                if (newCategory.IsCategoryNameExistInDb((dtoName as CategoryDTO).CategoryName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Category");
                }
                else
                {
                    newCategory.InsertNewCategory((dtoName as CategoryDTO).CategoryName);
                    resultMessage = newCategory.GetCRUDResult();
                }
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk");
            }
        }
 // GET: Categories
 public ActionResult Index()
 {
     using (CategoriesDAL service = new CategoriesDAL())
     {
         var categories = service.GetData().ToList();
         if (TempData["Message"] != null)
         {
             ViewBag.msg = TempData["Message"].ToString();
         }
         return(View(categories));
     }
 }
Example #28
0
        public ActionResult CreateNews(string chkType, string chkAutoUpload, News newDetail)
        {
            try
            {
                if (string.IsNullOrEmpty(newDetail.Title))
                {
                    return(Json(new { msg = "Bạn phải nhập tiêu đề" }));
                }
                if (string.IsNullOrEmpty(newDetail.Summary))
                {
                    return(Json(new { msg = "Bạn phải nhập tóm tắt" }));
                }
                if (newDetail.CategoryID <= 0)
                {
                    return(Json(new { msg = "Bạn phải chọn chuyên mục" }));
                }
                if (newDetail.Id == 0)
                {
                    CategoriesDAL categoryCtrl = new CategoriesDAL();
                    var           category     = categoryCtrl.GetItemByID("Id", newDetail.CategoryID);

                    NewsDAL objCtrl = new NewsDAL();
                    newDetail.Type      = !string.IsNullOrEmpty(chkType) ? (byte)1 : (byte)0;
                    newDetail.Active    = 1;
                    newDetail.UnitId    = SysBaseInfor.GetCurrentUnitId().ToInt32();
                    newDetail.CreatedAt = DateTime.Now;
                    newDetail.CreatedBy = SysBaseInfor.GetCurrentUserId();
                    newDetail.Status    = isChief ? (byte)1 : (byte)0;
                    objCtrl.CreateItem(newDetail);

                    if (newDetail.Id > 0 && !string.IsNullOrEmpty(chkAutoUpload))
                    {
                        var tmpContent = UploadAllImageInNewsToServer(newDetail.FullContent, newDetail.Id);
                        if (!string.IsNullOrEmpty(tmpContent))
                        {
                            newDetail.FullContent = tmpContent;
                        }
                        objCtrl.UpdateItem(newDetail);
                    }
                    return(Json(new { msg = "Success", idNews = newDetail.Id, typeAction = "Create" }));
                }
                else
                {
                    return(Json(new { msg = "Thao tác không thực hiện được" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { msg = ex.Message }));
            }
        }
Example #29
0
 public ActionResult Create(Category category)
 {
     try
     {
         // TODO: Add insert logic here
         CategoriesDAL cat = new CategoriesDAL();
         cat.Create(category);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Delete(Category category)
        {
            try
            {
                CategoriesDAL categoriesDAL = new CategoriesDAL();
                categoriesDAL.Delete(category);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(Category category)
        {
            try
            {
                CategoriesDAL catDal = new CategoriesDAL();
                catDal.Create(category);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View());
            }
        }
        public ActionResult Index(int page = 1, int pageSize = 6)
        {

            CategoriesDAL c = new CategoriesDAL();
            List<CategoryDTO> categoryList = c.GetCategories();
            List<CategoryModel> modelList = new List<CategoryModel>();
            int i = 0;
            foreach (CategoryDTO x in categoryList)
            {
                CategoryModel m = new CategoryModel();
                m.id_categ = categoryList[i].id_categ;
                m.categ_name = categoryList[i].categ_name;
                modelList.Add(m);
                i++;
            }
            
            PagedList<CategoryModel> model = new PagedList<CategoryModel>(modelList, page, pageSize);
            return View(model);
        }
 public ActionResult Add(CategoryModel model)
 {
     CategoriesDAL category = new CategoriesDAL();
     CategoryDTO dto = new CategoryDTO();
     dto.categ_name = model.categ_name;
     try
     {
         if (ModelState.IsValid)
         {
             category.insertCategory(dto);
             return RedirectToAction("Index");
         }
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException) 
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(model);
 }
 //----------------Delete-------------------
 
 public ActionResult Delete(int id)
 {
     CategoriesDAL c = new CategoriesDAL();
     CategoryDTO dto = new CategoryDTO();
     dto = c.GetCategoryByID(id);
     try
     {
         c.deleteCategory(dto);
         return RedirectToAction("Index");
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException) 
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View();
 }