예제 #1
0
        public IActionResult Post([FromBody] CreateConnectionViewModel model)
        {
            var provider = _providers.FirstOrDefault(p => p.Id == model.ProviderId);

            if (provider == null)
            {
                return(NotFound("The requested provider is not found."));
            }
            try
            {
                var result = _connectionRepository.Create <ConnectionModel>(new
                {
                    model.Name,
                    model.Description,
                    model.ProviderId
                });

                _connectionRepository.LinkOptions(result, model.Options);

                _transaction.Commit();
                return(Ok(result));
            }
            catch
            {
                _transaction.Rollback();
                throw;
            }
        }