コード例 #1
0
        public async Task <ActionResult> Delete(int id)
        {
            var        repository = new SalesOrdersRepository(_context);
            SalesOrder salesOrder = await repository.GetById(id);

            if (salesOrder == null)
            {
                return(NotFound());
            }

            try
            {
                repository.Delete(salesOrder);
                repository.Save();

                return(NoContent());
            }
            catch (Exception e)
            {
                return(BadRequest(new
                {
                    message = e.Message.Replace('{', '(').Replace('}', ')')
                }));
            }
        }
コード例 #2
0
        public async Task <ActionResult> GetOrder(int id)
        {
            var        repository = new SalesOrdersRepository(_context);
            SalesOrder salesOrder = await repository.GetById(id);

            if (salesOrder == null)
            {
                return(NotFound());
            }
            return(Ok(salesOrder));
        }