Exemplo n.º 1
0
        public ActionResult News()
        {
            ViewBag.ActiveIndex = 2;
            var res = _ins.GetAll();

            return(View(res));
        }
Exemplo n.º 2
0
        private IndexVM GetIndexVm(int eventCount = int.MaxValue, int newCount = int.MaxValue)
        {
            IndexVM ivm = new IndexVM();

            _ias.Initialize(ServerPath);

            //news
            var news = _ns.GetAll().Take(newCount);

            foreach (var item in news)
            {
                File_t file = null;
                if (item.AlbumId.HasValue)
                {
                    file = _ias.GetAlbumById(item.AlbumId.Value, false).File_t.Where(f => f.IsOnTopAlbum).FirstOrDefault();
                }
                ivm.NewVMCollection.Add(

                    new IndexVM()
                {
                    AlbumId   = item.AlbumId,
                    Id        = item.Id,
                    IssueDate = item.IssueDate,
                    FilePath  = file != null ? file.NewThumPath : "null",
                    Text      = item.Text,
                    Title     = item.Title,
                    Location  = item.Location
                });
            }
            //events
            var events = _es.GetAll().Where(e => e.IssueDate >= DateTime.Now).Take(eventCount);
            var album  = _ias.GetEventAlbum();

            foreach (var item in events)
            {
                File_t file = null;
                if (item.FileId.HasValue)
                {
                    file = album.File_t.Where(f => f.Id == item.FileId.Value).FirstOrDefault();
                }
                ivm.EventVMCollection.Add(new IndexVM()
                {
                    Id        = item.Id,
                    IssueDate = item.IssueDate,
                    FilePath  = file != null ? file.NEWTHUM_FILE : "null",
                    Text      = item.Text,
                    Title     = item.Title,
                    Location  = item.Location
                });
            }
            return(ivm);
        }
Exemplo n.º 3
0
 public ActionResult Get()
 {
     try
     {
         var condominiums = _newService.GetAll();
         response.StatusCode = StatusCodes.Status200OK;
         response.Status     = "OK";
         response.Result     = condominiums;
         return(Ok(response));
     }
     catch (Exception e)
     {
         response.StatusCode = StatusCodes.Status400BadRequest;
         response.Status     = "BAD REQUEST";
         response.Message    = e.Message;
         return(BadRequest(response));
     }
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Index()
        {
            var currentCulture = CultureInfo.CurrentCulture.Name;

            var entity        = _productService.GetAll();
            var products      = _mapper.Map <List <ProductViewModel> >(entity);
            var productsTelek = new List <ProductViewModel>();
            var productsKomp  = new List <ProductViewModel>();
            var productsBit   = new List <ProductViewModel>();

            foreach (var product in products)
            {
                var productParentCategory = GetParentCategory(product.Category);
                if (productParentCategory.Name == "Компьютерная техника")
                {
                    productsKomp.Add(product);
                }
                else if (productParentCategory.Name == "Телевизоры и электроника")
                {
                    productsTelek.Add(product);
                }
                else if (productParentCategory.Name == "Бытовая техника")
                {
                    productsBit.Add(product);
                }
            }


            var entityCategories = _productCategoryService.GetAll();
            var categories       = _mapper.Map <List <ProductCategoryViewModel> >(entityCategories);

            var entityNews = await _newService.GetAll();

            var news = _mapper.Map <List <NewViewModel> >(entityNews).OrderByDescending(_ => _.Created).Take(3).ToList();

            return(View(new HomeViewModel {
                Products = products, ProductCategory = categories, News = news, ProductsTelek = productsTelek, ProductsBit = productsBit.Take(3).ToList(), ProductsKomp = productsKomp
            }));
        }
Exemplo n.º 5
0
 public ActionResult Get()
 {
     return(Ok(
                newService.GetAll()
                ));
 }
Exemplo n.º 6
0
        public async Task <IActionResult> News()
        {
            var news = _mapper.Map <List <NewViewModel> >(await _newService.GetAll());

            return(View(news));
        }