Пример #1
0
        public async Task <IActionResult> CreateNumber(int contactId, DetailInfoForUpdateDto details)
        {
            Number number = new Number();

            number.PhoneNumber = details.PhoneNumber;
            number.ContactId   = contactId;
            _repo.Add(number);
            await _repo.SaveAll();

            return(Ok());
        }
Пример #2
0
        internal PrototypeInMemoryContext WithTestData()
        {
            var fibonacciNumberSeriesValues = new Int64[] { 0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };

            using (var numberRepository = new NumberRepository(this))
            {
                for (var i = 0; i <= 100; i++)
                {
                    var number = new Number()
                    {
                        Identifier = Guid.NewGuid(),
                        Value      = i
                    };

                    numberRepository.Add(number);
                }

                SaveChanges();

                using (var numberSeriesRepository = new NumberSeriesRepository(this))
                {
                    numberSeriesRepository.Add(NumberSeries.Named.Fibonacci);
                    SaveChanges();

                    using (var numberSeriesNumberRepository = new NumberSeriesNumberRepository(this))
                    {
                        var fibonacciNumbers = numberRepository.FindWhere(entity => fibonacciNumberSeriesValues.Contains(entity.Value));

                        foreach (var fibonacciNumber in fibonacciNumbers)
                        {
                            var fibonacciNumberSeriesNumber = new NumberSeriesNumber()
                            {
                                Identifier             = Guid.NewGuid(),
                                NumberIdentifier       = fibonacciNumber.Identifier,
                                NumberSeriesIdentifier = NumberSeries.Named.Fibonacci.Identifier
                            };

                            numberSeriesNumberRepository.Add(fibonacciNumberSeriesNumber);
                        }

                        SaveChanges();
                    }
                }
            }

            return(this);
        }