public bool create_hoa_don(donhangkemct donhang) { try { int s = 0; for (int i = 0; i < donhang.ctdhs.Count(); i++) { s = donhang.ctdhs[i].soluong * donhang.ctdhs[i].gia; } donhang.dh.tinhtrang = 0; donhang.dh.tongtien = s; if (this.create(donhang.dh)) { List <donhang> ds = _context.donhangs.ToList(); int id = ds[ds.Count() - 1].id; for (int i = 0; i < donhang.ctdhs.Count(); i++) { chitietdonhang ct = new chitietdonhang(); ct.iddh = ct.iddh; ct.idmon = ct.idmon; ct.soluong = ct.soluong; ct.gia = ct.gia; } } return(true); } catch (Exception) { return(false); } }
public bool create_hoa_don([FromBody] donhangkemct donhang) { return(_Respo.create_hoa_don(donhang)); }