Пример #1
0
        public virtual async Task <TId> AddAsync(TEntity entity)
        {
            _dbSet.Add(entity);
            await _myDBContext.SaveChangesAsync();

            return(entity.Id);
        }
Пример #2
0
        public async Task <IActionResult> Add(Cliente cliente)
        {
            if (CPFValidation.Validate(cliente.CPF) && EmailValidation.Validate(cliente.Email))
            {
                if (ModelState.IsValid)
                {
                    Cliente existeCpf = await _sQLDbContext.Clientes.FirstOrDefaultAsync(m => m.CPF == cliente.CPF);

                    Cliente existeEmail = await _sQLDbContext.Clientes.FirstOrDefaultAsync(m => m.Email == cliente.Email);

                    if (existeCpf == null && existeEmail == null)
                    {
                        _sQLDbContext.Add(cliente);
                        await _sQLDbContext.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        return(RedirectToAction("Add", "Clientes"));
                    }
                }
            }
            return(View(cliente));
        }
Пример #3
0
 public async Task CompleteAsync()
 {
     await _context.SaveChangesAsync();
 }
Пример #4
0
 public Task <int> Complete()
 {
     return(context.SaveChangesAsync());
 }