public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var databarang = await _detailBeli.sortbyidbeli(id);

                foreach (var barang in databarang)
                {
                    var getdetailpembelian = await _detailBeli.getbyid(barang.DetailBeliId);

                    var datadetailbarang = await _Barang.GetById(barang.IdBarang);

                    datadetailbarang.Stok = Convert.ToInt16(datadetailbarang.Stok - barang.Qty);
                    await _detailBeli.Deletes(getdetailpembelian.DetailBeliId);

                    await _Barang.UpdateAsync(datadetailbarang);
                }
                await _Beli.Delete(id);

                return(Ok("Data berhasil didelete"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #2
0
        public async Task <DetailBeli> Get(string id)
        {
            var model = await _DetailBeli.getbyid(id);

            return(model);
        }