Пример #1
0
        public IActionResult Index()
        {
            var products = _productsRepository.GetProducts();
            var model    = new ProductsViewModel();
            var list     = new List <ProductViewModel>();

            foreach (var elem in products)
            {
                var category = _categoriesRepository.GetCategoryById(elem.CategoryId);
                var country  = _countriesRepository.GetCountryById(elem.CountryId);

                var product = new ProductViewModel();
                product.Id            = elem.Id;
                product.NameAr        = elem.NameAr;
                product.NameEn        = elem.NameEn;
                product.DescreptionAr = elem.DescreptionAr;
                product.DescreptionEn = elem.DescreptionEn;
                product.CreatedAt     = elem.CreatedAt;
                product.CountryName   = country.NameEn;
                product.CategoryName  = category.NameEn;

                list.Add(product);
            }

            model.Products = list;
            return(View(model));
        }
Пример #2
0
        public IActionResult Edit(int Id)
        {
            var country = _countriesRepository.GetCountryById(Id);
            var model   = new CountryModel {
                NameEn = country.NameEn, NameAr = country.NameAr, Id = Id, CreatedAt = country.CreatedAt, UpdatedAt = country.UpdatedAt
            };

            return(View(model));
        }