Exemplo n.º 1
0
        public async Task <Address> CreateAsync(Address c)
        {
            // add to database using EF Core
            EntityEntry <Address> added = await db.Addresses.AddAsync(c);

            int affected = await db.SaveChangesAsync();

            if (affected == 1)
            {
                // if the customer is new, add it to cache, else
                // call UpdateCache method
                return(addressesCache.AddOrUpdate(Convert.ToString(c.AddressId), c, UpdateCache));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public async Task <Space> CreateAsync(Space s)
        {
            // add to database using EF Core
            EntityEntry <Space> added = await db.Spaces.AddAsync(s);

            int affected = await db.SaveChangesAsync();

            if (affected == 1)
            {
                // if the space is new, add it to cache, else
                // call UpdateCache method
                return(spacesCaches.AddOrUpdate(Convert.ToString(s.AddressId), s, UpdateCache));
            }
            else
            {
                return(null);
            }
        }