Пример #1
0
 private void b_Add_Click(object sender, EventArgs e)
 {
     if (t_Name.Text == string.Empty || t_Price.Text == string.Empty || c_Catagory.SelectedItem.ToString() == string.Empty)
     {
         MessageBox.Show("Please enter values");
     }
     else
     {
         name = this.c_Catagory.SelectedItem.ToString();
         CategoryListService catListService = new CategoryListService();
         //id = catListService.GetIdByName(name);
         AddItemService addItemService = new AddItemService();
         int            result         = addItemService.Insert(new Item()
         {
             ItemName = t_Name.Text, ItemPrice = float.Parse(t_Price.Text), ItemDescription = t_Description.Text, Category_Name = name
         });
         if (result > 0)
         {
             MessageBox.Show("Item added.");
         }
         else
         {
             MessageBox.Show("Error");
         }
         t_Name.Text = t_Price.Text = t_Description.Text = string.Empty;
     }
 }
Пример #2
0
        private void b_search_Click(object sender, EventArgs e)
        {
            CategoryListService catListService = new CategoryListService();
            List <CategoryList> list           = new List <CategoryList>();

            list.Add(catListService.GetByName(t_CatName.Text));
            dataGridView1.DataSource = list;
        }
 public CarCategoryController(ILogger <CarCategoryController> logger, ContextEntity context)
 {
     _logger  = logger;
     _context = new BaseEntityRepository <CarCategory>(context);
     _save    = new CategorySaveService(_context);
     _delete  = new CategoryDeleteService(_context);
     _list    = new CategoryListService(_context);
 }
Пример #4
0
        private void AddItemForm_Load(object sender, EventArgs e)
        {
            CategoryListService catListService = new CategoryListService();
            var           list          = catListService.GetAll();
            List <string> categoryNames = new List <string>();

            foreach (var item in list)
            {
                categoryNames.Add(item.CategoryName);
            }
            c_Catagory.DataSource = categoryNames;
        }
        private void ItemListForm_Load(object sender, EventArgs e)
        {
            ItemListService itemListService = new ItemListService();

            dataGridView1.DataSource = itemListService.GetAll();

            CategoryListService catListService = new CategoryListService();
            var           list          = catListService.GetAll();
            List <string> categoryNames = new List <string>();

            foreach (var item in list)
            {
                categoryNames.Add(item.CategoryName);
            }
            comboBox1.DataSource = categoryNames;
        }
Пример #6
0
        public async Task TakeGuideCategoryShouldTakeAllGuideCategories()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);

            var postRepository  = new EfDeletableEntityRepository <Post>(context);
            var guideRepository = new EfDeletableEntityRepository <Guide>(context);
            var service         = new CategoryListService(postRepository, guideRepository);
            var model           = new GuideCategoryListViewModel();

            var actual = await service.TakeGuideCategoryAsync(model);

            var expected = Enum.GetNames(typeof(CategoryOfGuide)).Length;

            Assert.Equal(expected, actual.Categories.Count);
        }
Пример #7
0
        private void b_add_Click(object sender, EventArgs e)
        {
            CategoryListService catListService = new CategoryListService();
            int result = catListService.Insert(new CategoryList()
            {
                CategoryName = t_CatName.Text
            });

            if (result > 0)
            {
                MessageBox.Show("Category Added.");
                UpdateGridView();
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
Пример #8
0
        private void b_update_Click(object sender, EventArgs e)
        {
            CategoryListService catListService = new CategoryListService();
            CategoryList        category       = catListService.GetById(id);

            category.Id           = id;
            category.CategoryName = t_CatName.Text;
            int result = catListService.Update(category);

            if (result > 0)
            {
                MessageBox.Show("Category Updated.");
                UpdateGridView();
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
Пример #9
0
        private void CategoriesListForm_Load(object sender, EventArgs e)
        {
            CategoryListService catListService = new CategoryListService();

            dataGridView1.DataSource = catListService.GetAll();
        }
Пример #10
0
        void UpdateGridView()
        {
            CategoryListService catListService = new CategoryListService();

            dataGridView1.DataSource = catListService.GetAll();
        }
Пример #11
0
 public CategoryListController(CategoryListService _categorylistService)
 {
     categorylistService = _categorylistService;
 }
Пример #12
0
 public void Setup()
 {
     this._repository = new  FakeBaseRepository <CarCategory>();
     this._service    = new CategoryListService(_repository);
 }