示例#1
0
        public ActionResult ProductAddPopup(string btnId, string formId, int deliveryId, ProductListSelected request)
        {
            if (request.ProductIds != null)
            {
                if (!string.IsNullOrEmpty(request.ProductIds))
                {
                    var productIds = request.ProductIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var productId in productIds)
                    {
                        var id        = Int32.Parse(productId);
                        var isExisted = _deliveryService.CheckProductExistedInDelivery(deliveryId, id);
                        if (isExisted)
                        {
                            continue;
                        }
                        var deliveryDetailModel = new DeliveryDetailModel()
                        {
                            Quantity     = 1,
                            VatRate      = 0,
                            DiscountRate = 0,
                            ProductId    = id,
                            DeliveryId   = deliveryId,
                            UnitPrice    = 0
                        };
                        _deliveryService.InsertDeliveryDetail(deliveryDetailModel);
                    }
                }
            }

            return(RedirectToAction("Edit", new { id = deliveryId }));
        }