示例#1
0
        public async Task <SubBill> AddSubBill(SubBill subBill)
        {
            await _context.SubBills.AddAsync(subBill);

            await Save();

            return(subBill);
        }
示例#2
0
        public async Task <IActionResult> AddBill([FromBody] TotalBillAddDto[]  totalBillAddDto)

        {
            TotalBill totalBill = new TotalBill();
            double    total     = 0;
            //foreach (var bill in totalBillAddDto)
            //{
            //total += bill.price * bill.Quantity;
            //}
            //totalBill.SumTotal=total;

            List <SubBill> SubBillist = new List <SubBill>();
            SubBill        subBill;

            foreach (var subBillItem in totalBillAddDto)
            {
                subBill           = new SubBill();
                total            += subBillItem.price * subBillItem.Quantity;
                subBill.ProductId = subBillItem.ProductId;
                subBill.Quantity  = subBillItem.Quantity;
                subBill.price     = subBillItem.price;
                SubBillist.Add(subBill);
            }
            totalBill.SubBill  = SubBillist;
            totalBill.SumTotal = total;
            // var createSubBill = await _repTotalBill.AddSubBill(SubBillTocreate);
            await _repTotalBill.AddBill(totalBill);

            return(Ok());
            // for(let data of this.shoppingCartService.dataProducts){
            //   total += data.price * data.Quantity;
            // }

            //  var TotalBillTocreate = _mapper.Map<sub>(totalBillAddDto);
            // var createTotalBill = await _repTotalBill.AddBill(TotalBillTocreate);
            // totalBillAddDto.TotlBillId= createTotalBill.Id;
            //  var SubBillTocreate = _mapper.Map<IEnumerable<TotalBillAddDto>, IEnumerable<SubBill>>(totalBillAddDto);
            // totalBill.SubBill=SubBillTocreate;

            // var SubBillTocreate = _mapper.Map<SubBill>(totalBillAddDto);
        }