예제 #1
0
        public ActionResult ProductAddPopup(string btnId, string formId, int receiveId, 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 = _receiveService.CheckProductExistedInReceive(receiveId, id);
                        if (isExisted)
                        {
                            continue;
                        }
                        var receiveDetailModel = new ReceiveDetailModel()
                        {
                            Quantity     = 1,
                            VatRate      = 0,
                            DiscountRate = 0,
                            ProductId    = id,
                            ReceiveId    = receiveId,
                            UnitPrice    = 0
                        };
                        _receiveService.InsertReceiveDetail(receiveDetailModel);
                    }
                }
            }

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