예제 #1
0
        public IActionResult OrderCatalogArticle([FromForm] Models.Trbovlje.OrderCatalogArticleViewModel orderCatalogArticle)
        {
            if (!ModelState.IsValid)
            {
                return(View(orderCatalogArticle));
            }

            var dbOrderCatalogArticle = _dbContext.OrderCatalogArticles.FirstOrDefault(u => u.Id == orderCatalogArticle.Id);

            if (dbOrderCatalogArticle == null)
            {
                return(RedirectToAction("Index"));
            }

            _mapper.Map(orderCatalogArticle, dbOrderCatalogArticle);
            _dbContext.OrderCatalogArticles.Update(dbOrderCatalogArticle);
            _dbContext.SaveChanges();

            return(View(orderCatalogArticle));
        }