Beispiel #1
0
        public ActionResult UpdateSupplier(int supplierId)
        {
            ActionResult response;

            if (ModelState.IsValid)
            {
                try
                {
                    //Obtain supplier info from SQL using given ID.
                    SupplierDO supplierDO = _SupplierDAO.ObtainSupplierById(supplierId);

                    //Map DO to PO.
                    SupplierPO supplier = SupplierMapper.DoToPo(supplierDO);

                    //Give view page with obtained info.
                    response = View(supplier);
                }
                catch (SqlException sqlex)
                {
                    response = RedirectToAction("Error", "Shared");
                }
                catch (Exception ex)
                {
                    response = RedirectToAction("Error", "Shared");

                    Logger.ErrorLogPath = _LogPath;
                    Logger.ExceptionLog(ex);
                }
            }
            else
            {
                response = View();
            }
            return(response);
        }
Beispiel #2
0
        public ActionResult Index()
        {
            ActionResult response;

            try
            {
                //Obtain and store list of all suppliers from SQL.
                List <SupplierDO> allSuppliers = _SupplierDAO.ObtainAllSuppliers();

                //Map the DO info and store it in a PO list.
                List <SupplierPO> supplierInfo = SupplierMapper.FromDoToPo(allSuppliers);

                //Go to index view page giving info of the PO list.
                response = View(supplierInfo);
            }
            catch (SqlException sqlex)
            {
                response = RedirectToAction("Error", "Shared");
            }
            catch (Exception ex)
            {
                response = RedirectToAction("Error", "Shared");

                Logger.ErrorLogPath = _LogPath;
                Logger.ExceptionLog(ex);
            }

            return(response);
        }
Beispiel #3
0
        public ActionResult UpdateSupplier(SupplierPO form)
        {
            ActionResult response;

            if (ModelState.IsValid)
            {
                try
                {
                    //Map given info to DO.
                    SupplierDO supplierDO = SupplierMapper.PoToDo(form);

                    //Update supplier in SQL giving DO info.
                    _SupplierDAO.UpdateSupplier(supplierDO);

                    //Return to view all suppliers page.
                    response = RedirectToAction("Index", "Supplier");
                }
                catch (SqlException sqlex)
                {
                    response = RedirectToAction("Error", "Shared");
                }
                catch (Exception ex)
                {
                    response = RedirectToAction("Error", "Shared");

                    Logger.ErrorLogPath = _LogPath;
                    Logger.ExceptionLog(ex);
                }
            }
            else
            {
                response = View();
            }
            return(response);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a DataAccessFacade for accessing a MS SQL database
        /// </summary>
        /// <param name="test">For integration tests, set test = true to use test database</param>
        public DataAccessFacade(bool test = false)
        {
            if (!test)
            {
                //take the database information from a textfile.
                connectionString = File.ReadAllText("C:\\ConnectString.txt");
            }
            else
            {
                connectionString =
                    @"Data Source=localhost\SQLEXPRESS;Initial Catalog=LTTEST;Integrated Security=True";
            }

            //Creates a new instance of the mappers with the connection information
            paymentMapper     = new PaymentMapper(connectionString);
            customerMapper    = new CustomerMapper(connectionString);
            supplierMapper    = new SupplierMapper(connectionString);
            bookingMapper     = new BookingMapper(connectionString);
            paymentRuleMapper = new PaymentRuleMapper(connectionString);

            PartyMapper partyMapper = new PartyMapper();

            partyMapper.CustomerMapper = customerMapper;
            partyMapper.SupplierMapper = supplierMapper;

            paymentMapper.PartyMapper        = partyMapper;
            bookingMapper.CustomerMapper     = customerMapper;
            bookingMapper.SupplierMapper     = supplierMapper;
            paymentRuleMapper.CustomerMapper = customerMapper;
            paymentRuleMapper.SupplierMapper = supplierMapper;

            customerMapper.ReadAll();
            supplierMapper.ReadAll();
        }
        /// <summary>
        /// Initializes a DataAccessFacade for accessing a MS SQL database
        /// </summary>
        /// <param name="test">For integration tests, set test = true to use test database</param>
        public DataAccessFacade(bool test = false)
        {
            if (!test)
            {
                //take the database information from a textfile.
                connectionString = File.ReadAllText("C:\\ConnectString.txt");
            }
            else
            {
                connectionString =
                    @"Data Source=localhost\SQLEXPRESS;Initial Catalog=LTTEST;Integrated Security=True";
            }

            //Creates a new instance of the mappers with the connection information
            paymentMapper = new PaymentMapper(connectionString);
            customerMapper = new CustomerMapper(connectionString);
            supplierMapper = new SupplierMapper(connectionString);
            bookingMapper = new BookingMapper(connectionString);
            paymentRuleMapper = new PaymentRuleMapper(connectionString);

            PartyMapper partyMapper = new PartyMapper();

            partyMapper.CustomerMapper = customerMapper;
            partyMapper.SupplierMapper = supplierMapper;

            paymentMapper.PartyMapper = partyMapper;
            bookingMapper.CustomerMapper = customerMapper;
            bookingMapper.SupplierMapper = supplierMapper;
            paymentRuleMapper.CustomerMapper = customerMapper;
            paymentRuleMapper.SupplierMapper = supplierMapper;

            customerMapper.ReadAll();
            supplierMapper.ReadAll();
        }
Beispiel #6
0
        public async Task <List <SupplierDTO> > Get()
        {
            List <Supplier> suppliers = await appDbContext.Suppliers.ToListAsync();

            List <SupplierDTO> supplierDTOs = new List <SupplierDTO>();

            for (int cnt = 0; cnt < suppliers.Count; cnt++)
            {
                supplierDTOs.Add(SupplierMapper.SupplierToDTO(suppliers[cnt]));
            }

            return(supplierDTOs);
        }
        public ProductImportViewModel()
        {
            InitializeCommands();

            m_Suppliers  = SupplierMapper.GetAllSuppliers();
            m_Producers  = ProducerMapper.GetAllProducers();
            m_Sorts      = SortMapper.GetAllSorts();
            m_Categories = ToolConstants.DEFAULT_FRUIT_CATEGORIES;
            m_Products   = ProductMapper.GetAllProducts();
            m_Origins    = CountryMapper.GetAllCountries();


            RaisePropertyChanged(nameof(Products));
            RaisePropertyChanged(nameof(Sorts));
            RaisePropertyChanged(nameof(Categories));
            RaisePropertyChanged(nameof(Origins));
        }
        private void OnDeleteSupplier()
        {
            if (m_Suppliers.Contains(m_CurrentSupplier))
            {
                if (System.Windows.MessageBox.Show(
                        string.Format("Möchten Sie den Lieferanten \"{0}\" löschen?", m_CurrentSupplier), "Delete Supplier?", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes)
                {
                    m_Suppliers.Remove(m_CurrentSupplier);
                    RaisePropertyChanged(nameof(Suppliers));

                    SupplierMapper.DeleteSupplier(m_CurrentSupplier.Id);

                    m_CurrentSupplier = null;
                    RaisePropertyChanged(nameof(CurrentSupplier));
                }
            }
        }
        private void OnSaveSupplier()
        {
            if (CheckSupplier())
            {
                if (!m_Suppliers.Contains(m_CurrentSupplier))
                {
                    m_Suppliers.Add(m_CurrentSupplier);
                    SupplierMapper.SaveSupplier(m_CurrentSupplier);

                    RaisePropertyChanged(nameof(Suppliers));
                }
                m_CurrentSupplier = null;
                RaisePropertyChanged(nameof(CurrentSupplier));

                m_SupplierHeader = "Lieferant";
                RaisePropertyChanged(nameof(SupplierHeader));

                m_NewSupplierVisible = false;
                RaisePropertyChanged(nameof(m_NewSupplierVisible));
            }
        }
Beispiel #10
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);
        }
Beispiel #11
0
        public ActionResult CreateSupplier(SupplierPO form)
        {
            ActionResult response;

            //Check if valid info was given, Back to create supplier view page if not.
            if (ModelState.IsValid)
            {
                try
                {
                    //Map given info to DO.
                    SupplierDO newSupplier = SupplierMapper.PoToDo(form);

                    //Create supplier in SQL, giving DO info.
                    _SupplierDAO.CreateSupplier(newSupplier);

                    //Return to view all supplier page.
                    response = RedirectToAction("Index", "Supplier");
                }
                catch (SqlException sqlex)
                {
                    response = RedirectToAction("Error", "Shared");
                }
                catch (Exception ex)
                {
                    response = RedirectToAction("Error", "Shared");

                    Logger.ErrorLogPath = _LogPath;
                    Logger.ExceptionLog(ex);
                }
            }
            else
            {
                response = View();
            }
            return(response);
        }
 public override SupplierContract Map(Supplier source)
 {
     return(SupplierMapper.Map(source));
 }
Beispiel #13
0
 public SupplierRepository()
 {
     _supplierMapper = new SupplierMapper();
 }