Ejemplo n.º 1
0
        public JsonResult Addresses(int id)
        {
            var item  = SalesQuote.TryFind(id);
            var query = from x in item.Customer.Addresses
                        select new {
                value = x.Id,
                text  = x.ToString()
            };

            return(Json(query.ToList(), JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult Confirm(int id)
        {
            var entity = SalesQuote.TryFind(id);

            entity.IsCompleted = true;


            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult AddItem(int order, int product)
        {
            var entity = SalesQuote.TryFind(order);
            var p      = Product.TryFind(product);
            int pl     = entity.Customer.PriceList.Id;
            var cost   = (from x in ProductPrice.Queryable
                          where x.Product.Id == product && x.List.Id == 0
                          select x).SingleOrDefault();
            var price = (from x in ProductPrice.Queryable
                         where x.Product.Id == product && x.List.Id == pl
                         select x).SingleOrDefault();
            var discount = (from x in CustomerDiscount.Queryable
                            where x.Product.Id == product && x.Customer.Id == entity.Customer.Id
                            select x.Discount).SingleOrDefault();

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            if (cost == null)
            {
                cost = new ProductPrice {
                    Value = decimal.Zero
                };
            }

            if (price == null)
            {
                price = new ProductPrice {
                    Value = decimal.MaxValue
                };
            }

            var item = new SalesQuoteDetail {
                SalesQuote    = entity,
                Product       = p,
                ProductCode   = p.Code,
                ProductName   = p.Name,
                TaxRate       = p.TaxRate,
                IsTaxIncluded = p.IsTaxIncluded,
                Quantity      = p.MinimumOrderQuantity,
                Price         = price.Value,
                DiscountRate  = discount,
                Currency      = entity.Currency,
                ExchangeRate  = entity.ExchangeRate
            };

            if (p.Currency != entity.Currency)
            {
                item.Price = price.Value * CashHelpers.GetTodayExchangeRate(p.Currency, entity.Currency);
            }

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

            return(Json(new {
                id = item.Id
            }));
        }