Exemple #1
0
        public ActionResult Cancel(int id)
        {
            var entity = SalesOrder.Find(id);

            if (!entity.IsCompleted || entity.IsCancelled || entity.IsPaid)
            {
                return(RedirectToAction("Index"));
            }

            entity.Updater          = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;
            entity.IsCancelled      = true;

            using (var scope = new TransactionScope()) {
                foreach (var item in entity.Payments)
                {
                    var payment = PaymentOnDelivery.Find(item.Id);
                    if (payment != null)
                    {
                        payment.DeleteAndFlush();
                    }
                    item.Delete();
                }

                entity.UpdateAndFlush();
            }

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public JsonResult RemovePayment(int id)
        {
            var item = SalesOrderPayment.Find(id);

            using (var scope = new TransactionScope()) {
                PaymentOnDelivery payment = PaymentOnDelivery.Queryable.FirstOrDefault(x => x.CustomerPayment == item.Payment);
                if (payment != null)
                {
                    payment.DeleteAndFlush();
                }

                item.DeleteAndFlush();
                item.Payment.DeleteAndFlush();
            }

            return(Json(new {
                id = id,
                result = true
            }));
        }