Пример #1
0
        /// <summary>
        /// Pat Banks
        /// Created:  2015/04/11
        /// Returns the result of approving a supplier application and adds records to the Supplier Table and SupplierLogin tables
        /// </summary>
        /// <param name="oldSupplierApp">The SupplierApplication object to be updated</param>
        /// <param name="updatedSupplierApp">The SupplierApplication object with the updated information</param>
        /// <param name="userName">The username of the Supplier</param>
        /// <param name="supplyCost">The supplier's portion of ticket proceeds</param>
        /// <returns>An enumerated result depicting pass or fail</returns>
        public SupplierResult ApproveSupplierApplication(SupplierApplication oldSupplierApp, SupplierApplication updatedSupplierApp, string userName, decimal supplyCost)
        {
            try
            {
                PasswordManager myPass   = new PasswordManager();
                string          password = myPass.supplierHash(userName, "Password#1");
                //Approving
                //update db with approval, add supplier record, add supplier login
                int numRows = SupplierApplicationAccessor.UpdateSupplierApplication(oldSupplierApp, updatedSupplierApp, userName, supplyCost, password);

                if (numRows == 3)
                {
                    //refresh cache
                    DataCache._currentSupplierList = SupplierAccessor.GetSupplierList();
                    DataCache._SupplierListTime    = DateTime.Now;
                    return(SupplierResult.Success);
                }
                return(SupplierResult.ChangedByOtherUser);
            }
            catch (SqlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
 /// <summary>
 /// Matt Lapka
 /// Created: 2015/02/08
 /// Gets a list of Pending Supplier Application Records from the Data Access layer
 /// Throws any exceptions caught by the DAL
 /// </summary>
 /// <returns>List of SupplierApplication objects</returns>
 public List <SupplierApplication> RetrieveSupplierApplicationList()
 {
     try
     {
         return(SupplierApplicationAccessor.GetSupplierApplicationList());
     }
     catch (Exception)
     {
         throw new Exception("No applications.");
     }
 }
Пример #3
0
 /// <summary>
 /// Matt Lapka
 /// Created:  2015/02/08
 /// Gets a single Supplier Application Record from the Data Access layer
 /// Throws any exceptions caught by the DAL
 /// </summary>
 /// <param name="applicationID">The string ID of the application to be retrieved</param>
 /// <returns>A SupplierApplication object whose applicationID matches the passed parameter</returns>
 public SupplierApplication RetrieveSupplierApplication(string applicationID)
 {
     try
     {
         return(SupplierApplicationAccessor.GetSupplierApplication(applicationID));
     }
     catch (Exception)
     {
         throw new Exception("Application does not exist.");
     }
 }
Пример #4
0
 /// <summary>
 /// Matt Lapka
 /// Created: 2015/02/08
 /// Add a single Supplier Application Record to the database
 /// Throws any exceptions caught by the DAL
 /// </summary>
 /// <remarks>
 /// Pat Banks
 /// Updated:  2015/04/11
 /// Added logic for returning the result of the operations to the presentation layer
 /// </remarks>
 /// <param name="newSupplier">Supplier object containing the information of the supplier to be added</param>
 /// <returns>An int reflecting the number of rows affected</returns>
 public SupplierResult AddASupplierApplication(SupplierApplication newSupplierApp)
 {
     try
     {
         return(SupplierApplicationAccessor.AddSupplierApplication(newSupplierApp) == 1 ? SupplierResult.Success : SupplierResult.NotAdded);
     }
     catch (ApplicationException ex)
     {
         return(ex.Message == "Concurrency Violation" ? SupplierResult.ChangedByOtherUser : SupplierResult.DatabaseError);
     }
     catch (Exception)
     {
         return(SupplierResult.DatabaseError);
     }
 }
Пример #5
0
        /// <summary>
        /// Matt Lapka
        /// Created: 2015/02/08
        /// Updates a Supplier Application Record
        /// Throws any exceptions caught by the DAL
        /// </summary>
        /// <remarks>
        /// Pat Banks
        /// Updated:  2015/04/11
        /// Added logic for returning the result of the operations to the presentation layer
        /// </remarks>
        /// <param name="newSupplier">Supplier object containing the new information of the supplier</param>
        /// <param name="oldSupplier">Supplier object containing the current information of the supplier to be matched to salve concurrency problems</param>
        /// <returns>An int reflecting the of rows affected</returns>
        public SupplierResult EditSupplierApplication(SupplierApplication oldSupplierApp, SupplierApplication updatedSupplierApp)
        {
            try
            {
                if (updatedSupplierApp.ApplicationStatus.Equals(ApplicationStatus.Pending.ToString()))
                {
                    //just editing application - still Pending
                    //update db with new info not related to approval
                    int numRows = SupplierApplicationAccessor.UpdateSupplierApplication(oldSupplierApp, updatedSupplierApp);

                    if (numRows == 1)
                    {
                        RetrieveSupplierApplicationList();
                        return(SupplierResult.Success);
                    }
                    return(SupplierResult.ChangedByOtherUser);
                }
                //Rejecting the application
                if (updatedSupplierApp.ApplicationStatus.Equals(ApplicationStatus.Rejected.ToString()))
                {
                    //update db with rejection
                    int numRows = SupplierApplicationAccessor.UpdateSupplierApplication(oldSupplierApp, updatedSupplierApp);

                    return(numRows == 1 ? SupplierResult.Success : SupplierResult.ChangedByOtherUser);
                }
                return(SupplierResult.NotChanged);
            }
            catch (ApplicationException ex)
            {
                return(ex.Message == "Concurrency Violation." ? SupplierResult.ChangedByOtherUser : SupplierResult.DatabaseError);
            }
            catch (Exception)
            {
                return(SupplierResult.DatabaseError);
            }
        }