コード例 #1
0
        public static void UpdateChargesOnOrderEdit(Order order)
        {
            TCRMDBContext _db         = new TCRMDBContext();
            List <Charge> chargesList = _db.Charges.Where(c => c.OrderID == order.ID).ToList <Charge>();

            if (chargesList == null)
            {
                return;
            }
            if (order.Status == false)
            {
                foreach (Charge chargeItem in chargesList)
                {
                    chargeItem.IsValid          = false;
                    _db.Entry(chargeItem).State = EntityState.Modified;
                }
            }
            if (order.Status == true)
            {
                foreach (Charge chargeItem in chargesList)
                {
                    chargeItem.IsValid          = true;
                    _db.Entry(chargeItem).State = EntityState.Modified;
                }
            }
            //save changes to DB
            _db.SaveChanges();
        }
コード例 #2
0
 public ActionResult Edit(PayCondition payconditions)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payconditions).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(payconditions));
 }
コード例 #3
0
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductTypeID = new SelectList(db.ProductTypes, "ID", "Description", product.ProductTypeID);
     return(View(product));
 }
コード例 #4
0
 public ActionResult Edit(ConversionRate conversionrate)
 {
     if (ModelState.IsValid)
     {
         db.Entry(conversionrate).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "FullDescription", conversionrate.CurrencyID);
     return(View(conversionrate));
 }
コード例 #5
0
 public ActionResult Edit(OrderItem orderitem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderitem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", orderitem.ProductID);
     return(View(orderitem));
 }
コード例 #6
0
 public ActionResult Edit(GlobalParameters globalparameters)
 {
     if (ModelState.IsValid)
     {
         db.Entry(globalparameters).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     //ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "FullDescription", globalparameters.CurrencyID);
     return(View(globalparameters));
 }
コード例 #7
0
 public ActionResult Edit(Distributor distributor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(distributor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CountryID  = new SelectList(db.Countries, "ID", "Description", distributor.CountryID);
     ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "FullDescription", distributor.CurrencyID);
     return(View(distributor));
 }
コード例 #8
0
 public ActionResult Edit(Charge charge)
 {
     if (ModelState.IsValid)
     {
         try
         {
             // if the charge status has changed to active check that the order is active
             bool chargeStatus = (bool)TempData["ChargeStatus"];
             if ((charge.IsValid != chargeStatus) && charge.IsValid == true)
             {
                 Order orderForCharge = db.Orders.Find(charge.OrderID);
                 if (orderForCharge.Status == false)
                 {
                     throw new Exception("Can't Change charge to active - charge order is not Active.");
                 }
             }
             OrderUtilities.IsChargeAlert(charge);
             db.Entry(charge).State = EntityState.Modified;
             db.SaveChanges();
             if (TempData["CameFromIndexFromOrderScreen"] != null)
             {
                 if ((bool)TempData["CameFromIndexFromOrderScreen"] == true)
                 {
                     return(RedirectToAction("IndexFromOrderScreen", "Charge", new { id = charge.OrderID }));
                 }
                 else
                 {
                     return(RedirectToAction("Index"));
                 }
             }
             return(RedirectToAction("Index"));
         }
         catch (Exception e)
         {
             ErrorSignal.FromCurrentContext().Raise(e);
             ViewBag.errorMessage = e.Message;
             ViewBag.route        = "Index";
             return(View("Exception"));
         }
     }
     return(View(charge));
 }
コード例 #9
0
        public static void UpdateOrderOnClientEdit(Client client)
        {
            TCRMDBContext _db        = new TCRMDBContext();
            List <Order>  ordersList = _db.Orders.Where(o => o.ClientID == client.ID).ToList <Order>();

            if (ordersList == null)
            {
                return;
            }
            foreach (Order order in ordersList)
            {
                order.Status = false;
                //also make all the charges for this order not active
                UpdateChargesOnOrderEdit(order);
                _db.Entry(order).State = EntityState.Modified;
            }

            //save changes to DB
            _db.SaveChanges();
        }
コード例 #10
0
 public ActionResult Edit(Client client)
 {
     if (ModelState.IsValid)
     {
         db.Entry(client).State = EntityState.Modified;
         //check if client status has changed to not active
         bool clientStatus = (bool)TempData["ClientStatus"];
         if ((client.Status != clientStatus) && (client.Status == false))
         {
             OrderUtilities.UpdateOrderOnClientEdit(client);
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DistributorID  = new SelectList(db.Distributors, "ID", "Name", client.DistributorID);
     ViewBag.ActivityTypeID = new SelectList(db.ActivityTypes, "ID", "Description", client.ActivityTypeID);
     ViewBag.CountryID      = new SelectList(db.Countries, "ID", "Description", client.CountryID);
     ViewBag.PayTypeID      = new SelectList(db.PayTypes, "ID", "Description", client.PayTypeID);
     ViewBag.CurrencyID     = new SelectList(db.Currencies, "ID", "FullDescription", client.CurrencyID);
     return(View(client));
 }
コード例 #11
0
        public ActionResult Edit(Order order)
        {
            bool uneditedOrderStatus;

            try
            {
                uneditedOrderStatus = (bool)TempData["uneditedOrderStatus"];
                if (ModelState.IsValid)
                {
                    if (uneditedOrderStatus != order.Status)
                    {
                        Client clientOrder = db.Clients.Find(order.ClientID);

                        if ((order.Status == true) && (clientOrder.Status == false))
                        {
                            throw new Exception("Can't Change order Status To Active if the Order's Client is not Active");
                        }
                        else
                        {
                            OrderUtilities.UpdateChargesOnOrderEdit(order);
                        }
                    }
                    db.Entry(order).State = EntityState.Modified;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ErrorSignal.FromCurrentContext().Raise(e);
                ViewBag.errorMessage = e.Message;
                ViewBag.route        = "Index";
                return(View("Exception"));
            }
            ViewBag.ClientID       = new SelectList(db.Clients, "ID", "Name", order.ClientID);
            ViewBag.PayConditionID = new SelectList(db.PayConditions, "ID", "Description", order.PayConditionID);
            //ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "Description", order.CurrencyID);
            return(View(order));
        }