Ejemplo n.º 1
0
        public void TestCategoryFinder()
        {
            int categoryId = 6;

            CategoryFinder  categoryFinder  = new CategoryFinder();
            CategoryGateway categoryGateway = categoryFinder.FindCategoryGatewayById(categoryId);

            Assert.AreEqual(categoryId, categoryGateway.CategoryID);
            Assert.AreEqual("Meat/Poultry", categoryGateway.CategoryName);
            Assert.AreEqual("Prepared meats", categoryGateway.Description);
        }
Ejemplo n.º 2
0
        protected override async Task OnInitializedAsync()
        {
            var result = await CategoryGateway.GetCategoriesWithIdNameAndDescription();

            if (result.IsValid)
            {
                Categories = result.Success;
            }

            IsValid = result.IsValid;
        }
Ejemplo n.º 3
0
        public async Task can_create_find_update_delete_a_budget()
        {
            BudgetGateway sut = new BudgetGateway(TestHelpers.ConnectionString);

            int      categoryId = 0;
            DateTime date1      = TestHelpers.RandomBirthDate(1);
            DateTime date2      = TestHelpers.RandomBirthDate(2);
            int      amount     = 50;
            int      collocId   = 0;

            Result <int> budgetResult = await sut.CreateBudget(categoryId, date1, date2, amount);

            Assert.That(budgetResult.Status, Is.EqualTo(Status.Created));

            int budgetId = budgetResult.Content;

            Result <BudgetData> budgetData;
            {
                budgetData = await sut.FindBudgetById(budgetId);

                checkBudget(budgetData, categoryId, date1, date2, amount, collocId);
            }
            {
                CategoryGateway categoryGateway = new CategoryGateway(TestHelpers.ConnectionString);
                Result <int>    result          = await categoryGateway.CreateCategory(TestHelpers.RandomTestName(), TestHelpers.RandomTestName(), 0);

                categoryId = result.Content;
                CollocGateway collocGateway = new CollocGateway(TestHelpers.ConnectionString);
                Result <int>  result1       = await collocGateway.CreateColloc(TestHelpers.RandomTestName(), 0);

                collocId = result.Content;
                amount   = 100;
                date1    = TestHelpers.RandomBirthDate(2);
                date2    = TestHelpers.RandomBirthDate(3);
                await sut.UpdateBudget(budgetId, categoryId, date1, date2, amount, collocId);

                budgetData = await sut.FindBudgetById(budgetId);

                checkBudget(budgetData, categoryId, date1, date2, amount, collocId);
            }
            {
                Result r = await sut.DeleteBudget(budgetId);

                Assert.That(r.Status, Is.EqualTo(Status.Ok));

                budgetData = await sut.FindBudgetById(budgetId);

                Assert.That(budgetData.Status, Is.EqualTo(Status.NotFound));
            }
        }
Ejemplo n.º 4
0
 public IHttpActionResult LoadSubCategory(int categoryType, int parentId)
 {
     try
     {
         var data = new CategoryGateway().GetSubCategory(categoryType, parentId);
         if (data == null)
         {
             return(InternalServerError(exception: new ApplicationException(message: "Server temporarily unavailable.")));
         }
         return(Ok(data));
     }
     catch (Exception ex)
     {
         return(InternalServerError(exception: ex));
     }
 }
Ejemplo n.º 5
0
        public void TestIdentityMapOfCategoryFinder()
        {
            int categoryId        = 6;
            int anotherCategoryId = 8;

            CategoryFinder  categoryFinder   = new CategoryFinder();
            CategoryGateway categoryGateway1 = categoryFinder.FindCategoryGatewayById(categoryId);
            CategoryGateway categoryGateway2 = categoryFinder.FindCategoryGatewayById(categoryId);

            Assert.AreEqual(categoryGateway1, categoryGateway2);

            CategoryGateway categoryGateway3 = categoryFinder.FindCategoryGatewayById(anotherCategoryId);

            Assert.AreNotEqual(categoryGateway1, categoryGateway3);
            Assert.AreNotEqual(categoryGateway2, categoryGateway3);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <DAL_EF.EF.RetailContext>();

            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["RetailContext"].ConnectionString);
            StandardKernel kernel = new StandardKernel(
                new UIModule(optionsBuilder.Options));

            IProductService  product  = kernel.Get <IProductService>();
            ICategoryService category = kernel.Get <ICategoryService>();
            ISupplierService supplier = kernel.Get <ISupplierService>();

            var cat = new CategoryDTO()
            {
                Name = "smth43242"
            };

            /*prod.Category=cat;
             * prod1.Category=cat;
             * prod2.Category=cat;*/

            /*category.Create(cat);
            *
            *  var prod = new ProductDTO () {Name= "smth", CategoryId=1, Price = 10};
            *  var prod1 = new ProductDTO () {Name= "smth1", CategoryId=1, Price= 20};
            *
            *
            *  var sup = new SupplierDTO () {Name="sm", Products= new List<ProductDTO> {prod, prod1}};
            *  supplier.Create(sup);*/

            //Console.WriteLine(product.GetWithMaxPrice().ProductId);
            //Console.WriteLine(product.GetWithMinPrice().ProductId);

            ProductGateway  prod  = new ProductGateway(new SqlContext());
            CategoryGateway categ = new CategoryGateway(new SqlContext());

            categ.Create(new ADOCategory()
            {
                Name = "Category"
            });

            prod.Create(new ADOProduct()
            {
                Name = "oof", Price = 10, CategoryId = 1
            });
        }
Ejemplo n.º 7
0
        protected async Task HandleSubmit()
        {
            if (!EditContext.Validate())
            {
                return;
            }

            if (MicroId == Guid.Empty)
            {
                await CategoryGateway.CreateCategory(Category);
            }
            else
            {
                await CategoryGateway.UpdateCategory(MicroId, Category);
            }

            NavigationManager.NavigateTo("/categories");
        }
Ejemplo n.º 8
0
 public ActionResult AddSubCategory(Category categroy)
 {
     ViewBag.CategoryType = CategoryType();
     if (ModelState.IsValid)
     {
         int rowAffected = new CategoryGateway().SaveSubCategory(categroy);
         if (rowAffected > 0)
         {
             ModelState.Clear();
             ViewBag.Success = "Sub Sub Category Added Successful.";
         }
         else
         {
             ViewBag.Error = "Sorry! Something get error!";
         }
     }
     return(View());
 }
Ejemplo n.º 9
0
        public async Task can_create_find_update_delete_category()
        {
            CategoryGateway sut = new CategoryGateway(TestHelpers.ConnectionString);

            string categoryName = TestHelpers.RandomTestName();
            string icon         = TestHelpers.RandomTestName();
            int    collocId     = 0;

            Result <int> categoryResult = await sut.CreateCategory(categoryName, icon, collocId);

            Assert.That(categoryResult.Status, Is.EqualTo(Status.Created));

            int categoryId = categoryResult.Content;

            Result <CategoryData> categoryData;
            {
                categoryData = await sut.FindCategoryId(categoryId);

                CheckCategory(categoryData, categoryName, icon, collocId);
            }
            {
                categoryName = TestHelpers.RandomTestName();
                icon         = TestHelpers.RandomTestName();
                CollocGateway coGateway = new CollocGateway(TestHelpers.ConnectionString);
                var           colloc    = await coGateway.CreateColloc(TestHelpers.RandomTestName(), 0);

                collocId = colloc.Content;
                await sut.UpdateCategory(categoryId, categoryName, icon, collocId);

                categoryData = await sut.FindCategoryId(categoryId);

                CheckCategory(categoryData, categoryName, icon, collocId);
            }

            {
                Result r = await sut.DeleteCategory(categoryId);

                Assert.That(r.Status, Is.EqualTo(Status.Ok));

                categoryData = await sut.FindCategoryId(categoryId);

                Assert.That(categoryData.Status, Is.EqualTo(Status.NotFound));
            }
        }
Ejemplo n.º 10
0
        protected override async Task OnInitializedAsync()
        {
            if (MicroId == Guid.Empty)
            {
                Category    = new Category();
                EditContext = new EditContext(Category);
                IsValid     = true;

                return;
            }

            var result = await CategoryGateway.GetCategoryById(MicroId);

            if (result.IsValid)
            {
                Category    = result.Success;
                EditContext = new EditContext(Category);
            }

            IsValid = result.IsValid;
        }
 public CategoryManager()
 {
     CategoryGateway = new CategoryGateway();
 }
Ejemplo n.º 12
0
 protected override AbstractGateway CreateGateway(IDataRecord reader)
 {
     return(CategoryGateway.Load(reader));
 }
 public CategoryManeger()
 {
     setupCategoryGateway = new CategoryGateway();
 }
Ejemplo n.º 14
0
 public ItemManager()
 {
     itemGateway     = new ItemGateway();
     companyGateway  = new CompanyGateway();
     categoryGateway = new CategoryGateway();
 }
Ejemplo n.º 15
0
 public CategoryController(CategoryGateway categoryGateway)
 {
     _categoryGateway = categoryGateway;
 }