Ejemplo n.º 1
0
        public async Task <HoAMember> Create(HoAMember member)
        {
            //Open a transaction. A line of communication to the database.
            IDbContextTransaction transaction = await DbContext.Database.BeginTransactionAsync();

            try
            {
                await DbContext.AddAsync(member);

                await DbContext.SaveChangesAsync();

                transaction.Commit();
            }
            finally
            {
                if (transaction != null)
                {
                    await transaction.DisposeAsync();
                }
            }

            HoAMember obj = await this.Read(member.Id);

            HoAMember product = obj;

            obj = default;
            return(product);
        }
Ejemplo n.º 2
0
        public async Task <HoAMember> Create(HoAMember member)
        {
            if (member.First == "Steve" && member.Last == "Karlsburg")
            {
                throw new ArgumentException("GET OUT OF HERE STEVE");
            }

            var product = await Repo.Create(member);

            return(product);
        }