コード例 #1
0
        public static Response UpdatePayment(int ID, string newType)
        {
            PaymentType oldPayment = PaymentRepositories.GetPaymentType(ID);

            if (oldPayment != null)
            {
                if (oldPayment.Type == newType)
                {
                    return(new Response(true));
                }

                PaymentType newPayment = PaymentRepositories.GetPaymentType(newType);
                if (newPayment == null)
                {
                    PaymentRepositories.UpdatePaymentType(oldPayment, newType);
                    return(new Response(true));
                }

                else
                {
                    return(new Response(false, "The new type has been taken."));
                }
            }

            return(new Response(false, "Theres no selected payment type."));
        }
コード例 #2
0
        public static Response InsertPaymentType(string name)
        {
            PaymentType checkPayment = PaymentRepositories.GetPaymentType(name);

            if (checkPayment == null)
            {
                PaymentType payment = PaymentFactories.InsertPaymentType(name);
                PaymentRepositories.InsertPaymentType(payment);
                return(new Response(true));
            }
            return(new Response(false, "Type must be unique"));
        }
コード例 #3
0
        public static Response DeletePayment(int ID)
        {
            if (TransactionRepositories.GetHeaderTransactionByPaymentID(ID) != null)
            {
                return(new Response(false, "Cant delete this payment type because its referenced on another table in the database"));
            }

            PaymentType payment = PaymentRepositories.GetPaymentType(ID);

            if (payment != null)
            {
                PaymentRepositories.DeletePaymentType(payment);
                return(new Response(true));
            }

            return(new Response(false, "Theres no selected payment type."));
        }
コード例 #4
0
 public static PaymentType GetPayment(int ID)
 {
     return(PaymentRepositories.GetPaymentType(ID));
 }
コード例 #5
0
 public static List <PaymentType> GetPaymentTypes()
 {
     return(PaymentRepositories.GetPaymentTypes());
 }