Ejemplo n.º 1
0
        public Foo(IBarFactory barFactory, IAsyncClassFactory asyncClassFactory)
        {
            string name = "This is from Foo";

            Bar = barFactory.Create(name);

            Task.Run(async() =>
            {
                ClassAsync = asyncClassFactory.Create(Bar);
                await ClassAsync.InitializeAsync();
            }).Wait();
        }
        public async Task AddAsync(string name, string imageURL, string phoneNumber, AddressDTO address)
        {
            if (context.Bars.Any(c => c.Name == name && c.IsDeleted == false))
            {
                throw new ArgumentException(OutputConstants.BarExists);
            }

            var bar = barFactory.Create(name, imageURL, phoneNumber, address);

            context.Bars.Add(bar);
            await context.SaveChangesAsync();
        }