Esempio n. 1
0
        private void SubmitMCreateEntityPriorityParseShouldWork()
        {
            const DataSourcePriority expected = DataSourcePriority.Trusted;
            var obj = new SubmitM {
                Priority = expected.ToString()
            };

            var actual = obj.CreateEntity(_user.Id).Priority;

            Assert.Equal(expected, actual);
        }
Esempio n. 2
0
        /// <summary>
        /// Method for creating a data source
        /// </summary>
        /// <param name = "data"> Data </param>
        /// <returns> </returns>
        public async Task <DataSourceVm> Create(SubmitM data, string userId)
        {
            var entity = data.CreateEntity(userId);

            if (await _context.DataSources.AnyAsync(ds => ds.Name == entity.Name))
            {
                throw new BadRequestException(nameof(Resource.DataSourceNameExists));
            }
            _context.DataSources.Add(entity);
            await _context.SaveChangesAsync();

            return(DataSourceVm.Create(entity));
        }