Exemplo n.º 1
0
        public async Task <bool> InsertOrUpdateCiliesListAsync(List <City> cities)
        {
            try
            {
                await _set.AddRangeAsync(cities);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public async Task <bool> InsertSubscriptionAsync(Subscription subscription)
        {
            Subscription oldRecord = await _set.FirstOrDefaultAsync(x => x.Email == subscription.Email && x.Category == subscription.Category);

            if (oldRecord != null)
            {
                return(false);
            }

            var result = await _set.AddAsync(subscription);

            if (result.State == EntityState.Added)
            {
                await _context.SaveChangesAsync();

                return(true);
            }

            return(false);
        }