/// <summary> /// Método que me permite cerrar la instancia del proxy /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { this.categoryBusiness = null; } this.categoryBusiness = null; disposedValue = true; } }
public ProductController() { this._unitOfWork = new UnitOfWork(_df); this._categoryBusiness = new CategoryBusiness(_df, this._unitOfWork); this._subCategoryBusiness = new SubCategoryBusiness(_df, this._unitOfWork); this._brandBusiness = new BrandBusiness(_df, this._unitOfWork); this._productBusiness = new ProductBusiness(_df, this._unitOfWork); this._productSizeBusiness = new ProductSizeBusiness(_df, this._unitOfWork); this._productAttributeBusiness = new ProductAttributeBusiness(_df, this._unitOfWork); this._ImageBusiness = new ImageBusiness(_df, this._unitOfWork); this._AddToCartBusiness = new AddToCartBusiness(_df, this._unitOfWork); this._WishListBusiness = new WishListBusiness(_df, this._unitOfWork); this._CompareListBusiness = new CompareListBusiness(_df, this._unitOfWork); }
public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here var lista = CategoryBusiness.GetCategoryList(); Category category = lista.Find(x => x.Id == id); lista.Remove(category); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(Category model) { try { // TODO: Add delete logic here //var lista = CategoryBusiness.GetCategoryList(); //Student category = lista.Find(x => x.Id == id); //lista.Remove(category); CategoryBusiness.Delete(model); return(RedirectToAction("Index")); } catch { return(View()); } }
// The following methods are responsible for updating information when it is changed. /// <summary> /// Updates the user control every time it is loaded. /// </summary> public void UpdateUserControl() { var eazyCartContext = new EazyCartContext(); this.categoryBusiness = new CategoryBusiness(eazyCartContext); this.productBusiness = new ProductBusiness(eazyCartContext); this.productReceiptBusiness = new ProductReceiptBusiness(eazyCartContext); this.receiptBusiness = new ReceiptBusiness(eazyCartContext); this.UpdateSelectProductTab(); this.UpdateReceiptTab(); this.UpdatePaidAmountAndChange(0); this.SetButtonAvailability(); this.highestProductReceiptId = this.productReceiptBusiness.GetHighestId(); this.currentProductReceiptId = this.highestProductReceiptId + 1; searchBoxTextBox.Focus(); }
public Category Add(Category category) { try { var bc = new CategoryBusiness(); return(bc.Add(category)); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public ActionResult Edit(int id, string name) { try { // TODO: Add update logic here var lista = CategoryBusiness.GetCategoryList(); Category category = lista.Find(x => x.Id == id); category.name = name; category.ChangedOn = DateTime.Now; return(RedirectToAction("Index")); } catch { return(View()); } }
public void Edit(Category category) { try { var bc = new CategoryBusiness(); bc.Edit(category); } catch (Exception ex) { var httpError = new HttpResponseMessage { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public void Remove(int id) { try { var bc = new CategoryBusiness(); bc.Remove(id); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
private void LoadData() { _CategoryBusiness = new CategoryBusiness(); currentAction = (int)ACTION.LOADING; ListCategory = _CategoryBusiness.GetCategoryList(); dgvListCategory.Rows.Clear(); for (int i = 0; i < ListCategory.Count; i++) { int inDex = dgvListCategory.Rows.Add(); dgvListCategory.Rows[inDex].Cells[0].Value = ListCategory[i].Id; dgvListCategory.Rows[inDex].Cells[1].Value = ListCategory[i].Name; } currentAction = (int)ACTION.NONE; if (ListCategory.Count > 0) { dgvListCategory.Rows[0].Selected = true; } }
public ProductPresenter(IProductView view) { if (Singleton <ProductBusiness> .Instance == null) { Singleton <ProductBusiness> .Instance = new ProductBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Product> >()); } _business = Singleton <ProductBusiness> .Instance; _businessPrice = new ProductPriceBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <ProductPrice> >()); _businessCategory = new CategoryBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Category> >()); _view = view; Product product = new Product(); var units = new UnitBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Unit> >()).GetAll().ToList(); var manufacturers = new ManufacturerBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Manufacturer> >()).GetAll().ToList(); _model = new ProductModel(product, units, manufacturers); _view.InitView(_model); }
// Create Category public async Task <ActionResult> CreateCategory(Category category) { ModelState.Remove("CreatedBy"); ModelState.Remove("ModifiedBy"); ModelState.Remove("CreatedDate"); ModelState.Remove("ModifiedDate"); var viewmodel = new CategoryViewModel(); if (ModelState.IsValid) { if (category.Id <= 0) { viewmodel = await CategoryBusiness.AddCategory(category); if (viewmodel.CategoryId != 0) { success = true; } else { success = false; } return(Json(new { success = success, data = viewmodel, IsEdit = false, JsonRequestBehavior.AllowGet })); } else { viewmodel = await CategoryBusiness.EditCategory(category); if (viewmodel.CategoryId != 0) { success = true; } else { success = false; } return(Json(new { success = success, data = viewmodel, IsEdit = true, JsonRequestBehavior.AllowGet })); } } return(RedirectToAction("AddCategory")); }
private void LoadComboBoxCategory() { #region combobox Category _CategoryBusiness = new CategoryBusiness(); List <CategoryDTO> lstCategory = new List <CategoryDTO>(); CategoryDTO category = new CategoryDTO(); category.Id = -1; category.Name = "Chọn Danh Mục"; lstCategory.Add(category); _lstCategory = _CategoryBusiness.GetCategoryList(); foreach (CategoryDTO item in _lstCategory) { lstCategory.Add(item); } cbCategory.DataSource = lstCategory; cbCategory.DisplayMember = "Name"; cbCategory.ValueMember = "Id"; #endregion }
public CategoryFindResponse Find(int id) { try { var response = new CategoryFindResponse(); var bc = new CategoryBusiness(); response.Result = bc.Find(id); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public AllResponse All() { try { var response = new AllResponse(); var bc = new CategoryBusiness(); response.ResultCategory = bc.All(); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public FindResponse <Category> Find(int id) { logger.Info($"Inicio de la busqueda de la categoria con id {id}"); try { var response = new FindResponse <Category>(); var bc = new CategoryBusiness(); response.Result = bc.Find(id); return(response); } catch (Exception ex) { logger.Error($"Error al obtener la categoria {id}", ex); var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
private void frmCategory_Load(object sender, EventArgs e) { CategoryBusiness pb = new CategoryBusiness(); List <CategoryTbl> categories = pb.GetAllCategory(); DataTable categoryData; if (categories != null && categories.Count > 0) { categoryData = Common.ListToDataTable(categories); if (categoryData != null) { dgvCategory.DataSource = categoryData; } else { MessageBox.Show("Some Error Occured in Convert List<T> to DataTable!"); } } else { MessageBox.Show("Categories table is empty!"); } }
public void Add_ThrowsArgumentException_WhenCategoryWithGivenIdExists() { // Arrange int duplicateId = 1; var data = new List <Category> { new Category { Name = "TestCategory1", Id = 1 } }.AsQueryable(); var mockSet = new Mock <DbSet <Category> >(); mockSet.As <IQueryable <Category> >().Setup(m => m.Provider).Returns(data.Provider); mockSet.As <IQueryable <Category> >().Setup(m => m.Expression).Returns(data.Expression); mockSet.As <IQueryable <Category> >().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As <IQueryable <Category> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(c => c.Categories).Returns(mockSet.Object); mockContext.Setup(c => c.SaveChanges()).Throws(new Exception()); var categoryBusiness = new CategoryBusiness(mockContext.Object); // Act & Assert try { categoryBusiness.Add("TestCategory1", duplicateId); Assert.Fail("No exception was thrown"); } catch (ArgumentException ex) { string expectedMessage = string.Format($"Category with ID {duplicateId} already exists."); Assert.AreEqual(expectedMessage, ex.Message, "Wrong exception was thrown."); } }
public ucCategory() { InitializeComponent(); categoryBusiness = new CategoryBusiness(); loaiSanPham = new LoaiSanPham(); }
public CategoryController(StoryContext StoryContextInstance) { this.StoryContextInstance = StoryContextInstance; this.CategoryBusinessInstance = new CategoryBusiness(this.StoryContextInstance); }
public AdminSubCategoryController() { this._unitOfWork = new UnitOfWork(_df); this._subcategoryBusiness = new SubCategoryBusiness(_df, this._unitOfWork); this._categoryBusiness = new CategoryBusiness(_df, this._unitOfWork); }
public CompanyUC() { InitializeComponent(); objCompanyBusiness = new CompanyBusiness(); objCategoryBusiness = new CategoryBusiness(); }
public AdminBrandController() { this._unitOfWork = new UnitOfWork(_df); this._brandBusiness = new BrandBusiness(_df, this._unitOfWork); this._categoryBusiness = new CategoryBusiness(_df, this._unitOfWork); }
//par public CategoryController(CategoryBusiness Category) { _Category = Category; }
/// <summary> /// Constructor de la clase que inicializa capa de negocio /// </summary> public CategoryService() { categoryBusiness = new CategoryBusiness(); }
public Category() { this.CreatedOn = DateTime.Now; this.ChangedOn = DateTime.Now; Id = CategoryBusiness.GetCategoryList().Count; }
// GET: Category public ActionResult Index() { var lista = CategoryBusiness.GetCategoryList(); return(View(lista)); }
public CategoryViewModel(CategoryBusiness categoryBusiness) { this.categoryBusiness = categoryBusiness; }
public CategoryController(CategoryBusiness categoryBusiness) : base(categoryBusiness) { }
public List <CategoryModel> GetListCategory() { CategoryBusiness cb = new CategoryBusiness(); return(cb.GetListCategory()); }