Ejemplo n.º 1
0
        public ActionResult Create(PayType paytype)
        {
            if (ModelState.IsValid)
            {
                db.PayTypes.Add(paytype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(paytype));
        }
Ejemplo n.º 2
0
        public ActionResult Create(PayCondition payconditions)
        {
            if (ModelState.IsValid)
            {
                db.PayConditions.Add(payconditions);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(payconditions));
        }
Ejemplo n.º 3
0
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductTypeID = new SelectList(db.ProductTypes, "ID", "Description", product.ProductTypeID);
            return(View(product));
        }
        public ActionResult Create(ConversionRate conversionrate)
        {
            if (ModelState.IsValid)
            {
                db.ConversionRates.Add(conversionrate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "FullDescription", conversionrate.CurrencyID);
            return(View(conversionrate));
        }
Ejemplo n.º 5
0
        public ActionResult Create(Distributor distributor)
        {
            if (ModelState.IsValid)
            {
                db.Distributors.Add(distributor);
                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));
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
        public ActionResult Create(Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(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));
        }
Ejemplo n.º 8
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));
 }
 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));
 }
Ejemplo n.º 10
0
        public ActionResult Create(Charge charge)
        {
            //check if the order is valid
            Order orderForCharge = db.Orders.Find(charge.OrderID);

            try
            {
                if (orderForCharge.Status == false)
                {
                    throw new Exception("Can't Create a charge for an unactive Order");
                }
            }
            catch (Exception e)
            {
                ErrorSignal.FromCurrentContext().Raise(e);
                ViewBag.errorMessage = e.Message;
                ViewBag.route        = "Index";
                return(View("Exception"));
            }
            //else connect client to charge using order ID
            int ClientID = orderForCharge.ClientID;

            charge.ClientID = ClientID;
            //check if model is valid
            if (ModelState.IsValid)
            {
                db.Charges.Add(charge);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientID = new SelectList(db.Clients, "ID", "Name", charge.ClientID);
            // populate orders dropdown only with orders which "IsPartOfService" = true
            ViewBag.OrderID = new SelectList(db.Orders.Where(o => o.EnumChargeFrequencyID != null), "ID", "ID", charge.OrderID);
            return(View(charge));
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
0
        public ActionResult SalePhase2(string orderItems)
        {
            List <OrderItem> orderItemsList = new List <OrderItem>();

            try
            {
                orderItemsList = JsonConvert.DeserializeObject <List <OrderItem> >(orderItems);
                //calculate orderItem net price based on conversion rates
                OrderUtilities.caculateOrderItemNetPriceWithConversion(orderItemsList);
            }
            catch (Exception e)
            {
                //write exception to elmah log
                ErrorSignal.FromCurrentContext().Raise(e);
                ViewBag.errorMessage = e.Message;
                ViewBag.route        = "SalePhase2";
                return(View("Exception"));
            }
            TempData["OrderItems"] = orderItemsList;
            double totalNetPrice      = 0;
            double partOfServicePrice = 0;

            foreach (OrderItem orderItem in orderItemsList)
            {
                totalNetPrice += orderItem.NetPrice;
                if (orderItem.IsPartOfService == true)
                {
                    partOfServicePrice += orderItem.NetPrice;
                }
            }
            TempData["partOfServicePrice"] = partOfServicePrice;
            TempData["totalNetPrice"]      = totalNetPrice;

            //incase the totalNetPriceForSupport=0 , we need to skip the
            // the charges screen and finish the order.

            if (partOfServicePrice == 0)
            {
                try
                {
                    Order orderWithoutCharges = new Order();
                    orderWithoutCharges           = (Order)TempData["orderPhase1"];
                    orderWithoutCharges.Status    = true;
                    orderWithoutCharges.NetPrice  = totalNetPrice;
                    orderWithoutCharges.orderItem = orderItemsList;

                    if (ModelState.IsValid)
                    {
                        db.Orders.Add(orderWithoutCharges);
                        foreach (OrderItem orderItem in orderItemsList)
                        {
                            db.OrderItems.Add(orderItem);
                        }
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception e)
                {
                    //write exception to elmah log
                    ErrorSignal.FromCurrentContext().Raise(e);
                    ViewBag.errorMessage = e.Message;
                    ViewBag.route        = "Index";
                    return(View("Exception"));
                }
            }
            TempData["RedirectFromPhase2"] = true;
            return(RedirectToAction("SalePhase3"));
        }