public async Task <ActionResult> Delete(int id) { var repository = new SalesOrderItemsRepository(_context); SalesOrderItem salesOrderItem = await repository.GetById(id); if (salesOrderItem == null) { return(NotFound()); } try { repository.Delete(salesOrderItem); repository.Save(); return(NoContent()); } catch (Exception e) { return(BadRequest(new { message = e.Message.Replace('{', '(').Replace('}', ')') })); } }
public async Task <ActionResult> GetOrder(int id) { var repository = new SalesOrderItemsRepository(_context); SalesOrderItem salesOrderItem = await repository.GetById(id); if (salesOrderItem == null) { return(NotFound()); } return(Ok(salesOrderItem)); }