public async Task UpdateRowInOrder(long orderId, long rowId, OrderRowModel updatedRow) { if (await OrderExists(orderId) == false) { throw new EntityNotFoundException <OrderModel>(orderId); } OrderRow row = await _db.OrderRows.FirstOrDefaultAsync(r => r.OrderId == orderId && r.Id == rowId); if (row == null) { throw new EntityNotFoundException <OrderRowModel>(rowId); } updatedRow.MapTo(row); await _db.SaveChangesAsync(); }
public async Task <OrderRowModel> AddRowToOrder(long id, OrderRowModel model) { if (await OrderExists(id) == false) { throw new EntityNotFoundException <OrderModel>(id); } var row = new OrderRow(); model.MapTo(row); row.OrderId = id; await _db.OrderRows.AddAsync(row); await _db.SaveChangesAsync(); return(row.MapToDto()); }