Exemplo n.º 1
0
        public ActionResult SetItemQuantity(int id, decimal value)
        {
            var entity = DeliveryOrderDetail.Find(id);

            var product = entity.Product;

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

            if (value >= 0 && value <= GetRemainQuantityBySalesOrderDetail(entity.OrderDetail))
            {
                entity.Quantity = value;
            }
            else
            {
                entity.Quantity = GetRemainQuantityBySalesOrderDetail(entity.OrderDetail);
            }

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

            return(Json(new {
                id = entity.Id,
                value = entity.FormattedValueFor(x => x.Quantity)
            }));
        }
Exemplo n.º 2
0
        public ActionResult SetItemProductName(int id, string value)
        {
            var    entity = DeliveryOrderDetail.Find(id);
            string val    = (value ?? string.Empty).Trim();

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

            if (val.Length == 0)
            {
                entity.ProductName = entity.Product.Name;
            }
            else
            {
                entity.ProductName = val;
            }

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

            return(Json(new {
                id = entity.Id,
                value = entity.ProductName
            }));
        }
Exemplo n.º 3
0
        public ActionResult RemoveItem(int id)
        {
            var entity = DeliveryOrderDetail.Find(id);

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

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

            return(Json(new { id = id, result = true }));
        }
Exemplo n.º 4
0
        public ActionResult Item(int id)
        {
            var item = DeliveryOrderDetail.Find(id);

            return(PartialView("_ItemEditorView", item));
        }