コード例 #1
0
        // GET: Products/Details/5
        public ActionResult Details(int id)
        {
            var product = _getProduct.Execute(id);

            if (product == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(product));
        }
コード例 #2
0
 // GET: Products/Edit/5
 public ActionResult Edit(int id)
 {
     try
     {
         var product = _getOne.Execute(id);
         return(View(product));
     }
     catch (EntityNotFoundException e)
     {
         return(RedirectToAction("Index"));;
     }
 }
コード例 #3
0
 public IActionResult Get(int id)
 {
     try
     {
         var product = _getOneCommand.Execute(id);
         return(Ok(product));
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500, "Doslo je do greske"));
     }
 }
コード例 #4
0
 public IActionResult Edit(long Id)
 {
     try
     {
         var product = _getProduct.Execute(Id);
         ViewBag.ProductInsertData = _getProductInsertData.Execute();
         return(View(product));
     }
     catch (EntityNotFoundException e)
     {
         TempData["Msg"] = e.Message;
         return(RedirectToAction("index"));
     }
     catch (Exception e)
     {
         TempData["Msg"] = e.Message;
         return(RedirectToAction("index"));
     }
 }