Beispiel #1
0
        public async Task <ActionResult <int> > CreateAsync([FromBody] CreateBuyerInput input)
        {
            var buyer = Buyer.Create(input.UserId, input.Name);

            await _context.Buyers.AddAsync(buyer);

            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = buyer.Id }, buyer.Id));
        }
Beispiel #2
0
        public void Create()
        {
            if (!_context.Buyers.Any())
            {
                var buyers = new Buyer[]
                {
                    Buyer.Create(Guid.NewGuid().ToString(), "Alice"),
                    Buyer.Create(Guid.NewGuid().ToString(), "Bob"),
                };

                _context.AddRange(buyers);
                _context.SaveChanges();
            }
        }