Пример #1
0
        public void CreateIssue(CreateIssueRequest issue, string userEmail)
        {
            if (issue is null)
            {
                throw new ArgumentNullException(nameof(issue));
            }

            var issueDbo = new Issue()
            {
                Description = issue.Description,
                LoggedBy    = userEmail
            };

            repository.Issue.Add(issueDbo);
            repository.SaveChanges();
        }
        /// <summary>
        /// Creates a problem
        /// </summary>
        /// <param name="problem">Problem to create</param>
        /// <returns>The created problem</returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="EntityNotFoundException"></exception>
        /// <exception cref="EntityWithNameAlreadyExistsException"></exception>
        /// <exception cref="InternalEntityNotFoundException"></exception>
        public ProblemResponse CreateUnverifiedProblem(CreateProblemRequest problem, string userEmail)
        {
            if (problem is null)
            {
                throw new ArgumentNullException(nameof(problem));
            }

            validator.Validate(problem);

            var problemDbo = AddUnverifiedProblemToDatabase(problem, userEmail);

            repository.SaveChanges();

            try
            {
                return(problemReader.GetProblem(problemDbo.Id));
            }
            catch (EntityNotFoundException exception)
            {
                throw new EntityCreationException(string.Empty, exception);
            }
        }
        public void Populate(bool validate)
        {
            string json             = File.ReadAllText(Path.ChangeExtension(Path.Combine(existingDataPath, "ExistingProblems"), "json"));
            var    existingProblems = JsonConvert.DeserializeObject <IEnumerable <ExistingProblem> >(json);

            if (validate)
            {
                foreach (var problem in existingProblems)
                {
                    ValidateProblem(problem);
                }
            }

            AddRulesToDatabase(existingProblems);

            StoreProblems(existingProblems, validate);
            repository.SaveChanges();
        }
Пример #4
0
        private void PopulateHolds()
        {
            if (repository.Hold == null)
            {
                throw new DatabaseException();
            }

            var holds = GetListOfEntities <ExistingHold>("Holds");

            foreach (var hold in holds)
            {
                repository.Hold.Add(new Hold()
                {
                    Id           = hold.Id,
                    Name         = hold.Name,
                    ParentHoldId = hold.ParentHoldId
                });
            }

            repository.SaveChanges();
        }