Exemplo n.º 1
0
        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('}', ')')
                }));
            }
        }
Exemplo n.º 2
0
        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));
        }