Ejemplo n.º 1
0
        public ActionResult ViewSupplierDetails(int supplierId)
        {
            ActionResult response;

            if (ModelState.IsValid)
            {
                try
                {
                    SupplierVM supplierDetails = new SupplierVM();

                    //Getting specific supplier info from SQL with ID and storing it into SupplierViewModel.
                    supplierDetails.SupplierData = SupplierMapper.DoToPo(_SupplierDAO.ObtainSupplierById(supplierId));

                    //Getting all products supplied by specific supplier ID and storing it into SupplierViewModel.
                    supplierDetails.ProductsBySupplier = ProductMapper.DOToPO(_ProductDAO.ObtainProductsBySupplierID(supplierId));

                    //View supplier details.
                    response = View(supplierDetails);
                }
                catch (SqlException sqlex)
                {
                    response = View("Error");
                }
                catch (Exception ex)
                {
                    response = View("Error");

                    Logger.ErrorLogPath = _LogPath;
                    Logger.ExceptionLog(ex);
                }
            }
            else
            {
                response = View();
            }

            return(response);
        }