Esempio n. 1
0
        public static List <PaymentMethodOption> GetPaymentMethodOptions()
        {
            auctionEntities      = new AuctionSystemEntities();
            paymentMethodOptions = new List <PaymentMethodOption>();

            //Retrieve the paymentmethods into an array from paymentmethod table in database.
            payment_method[] PaymentOptions = auctionEntities.payment_method.ToArray();

            //To check if paymentoptions array is empty, if null return paymentmehods list.
            if (PaymentOptions == null)
            {
                return(paymentMethodOptions);
            }

            //If not null then loop through the items in array
            foreach (payment_method paymentOption in PaymentOptions)
            {
                PaymentMethodOption PaymentMethodOption = new PaymentMethodOption()
                {
                    PaymentMethod_ID = paymentOption.id,
                    Payment_Method   = paymentOption.payment_method1
                };
                paymentMethodOptions.Add(PaymentMethodOption);
            }
            return(paymentMethodOptions);
        }
Esempio n. 2
0
        public ActionResult Edit(int id)
        {
            var item = PaymentMethodOption.Find(id);

            item.StoreId             = item.Store.Id;
            item.CommissionByManage *= 100m;

            return(PartialView("_Edit", item));
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            var item = PaymentMethodOption.Find(id);

            using (var scope = new TransactionScope()) {
                item.DeleteAndFlush();
            }
            return(PartialView("_Refresh"));
        }
Esempio n. 4
0
        public ActionResult Create(PaymentMethodOption item)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Create", item));
            }

            item.Store = Store.Find(item.StoreId);
            item.CommissionByManage /= 100m;

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(PartialView("_Refresh"));
        }
Esempio n. 5
0
        public JsonResult AddPayment(int id, int type, decimal amount, string reference, int?fee, bool ondelivery)
        {
            var dt          = DateTime.Now;
            var session     = GetSession();
            var store       = session.CashDrawer.Store;
            var sales_order = SalesOrder.Find(id);
            var employee    = CurrentUser.Employee;
            var item        = new SalesOrderPayment {
                SalesOrder = sales_order,
                Payment    = new CustomerPayment {
                    Creator          = employee,
                    CreationTime     = dt,
                    Updater          = employee,
                    ModificationTime = dt,
                    CashSession      = session,
                    /* SalesOrder = sales_order, */
                    Customer  = sales_order.Customer,
                    Method    = (PaymentMethod)type,
                    Amount    = amount,
                    Date      = DateTime.Now,
                    Reference = reference,
                    Currency  = sales_order.Currency
                },
                Amount = amount
            };

            if (fee.HasValue)
            {
                item.Payment.ExtraFee   = PaymentMethodOption.Find(fee.Value);
                item.Payment.Commission = item.Payment.ExtraFee.CommissionByManage;
            }

            // Store and Serial

            item.Payment.Store = store;

            try {
                item.Payment.Serial = (from x in CustomerPayment.Queryable
                                       where x.Store.Id == store.Id
                                       select x.Serial).Max() + 1;
            } catch {
                item.Payment.Serial = 1;
            }

            if (item.Amount > item.SalesOrder.Balance)
            {
                if (item.Payment.Method == PaymentMethod.Cash)
                {
                    item.Change = item.Amount - item.SalesOrder.Balance;
                }
                else
                {
                    item.Payment.Amount = item.SalesOrder.Balance;
                }

                item.Amount = item.SalesOrder.Balance;
            }

            if (ondelivery && !string.IsNullOrEmpty(sales_order.CustomerShipTo))
            {
                item.Payment.CashSession = null;
            }

            using (var scope = new TransactionScope()) {
                item.Payment.Create();
                item.CreateAndFlush();
            }

            return(Json(new {
                id = item.Id
            }));
        }
Esempio n. 6
0
 public ActionResult Delete(int id)
 {
     return(PartialView("_Delete", PaymentMethodOption.Find(id)));
 }