Esempio n. 1
0
 public async Task Delete(int id)
 {
     RPGCreated rpg = _context.RPGs.Find(id);
     if (rpg != null)
     {
         _context.RPGs.Remove(rpg);
         await _context.SaveChangesAsync();
     }
 }
Esempio n. 2
0
 public async Task Update(RPGCreated RPGChanges)
 {
     try
     {
         await _RPGCreatedRepository.Update(RPGChanges);
     }
     catch (Exception ex)
     {
         File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace);
         throw new Exception("Erro no banco de dados, contate o administrador");
     }
 }
Esempio n. 3
0
        public async Task Create(RPGCreated rpg)
        {
            List <Error> errors = new List <Error>();

            if (string.IsNullOrWhiteSpace(rpg.Name))
            {
                base.AddError("Nome", "O nome do RPG deve ser informado");
            }
            else if (rpg.Name.Length > 50)
            {
                base.AddError("Nome", "O nome do RPG deve conter até 50 caracteres");
            }
            base.CheckErrors();
            try
            {
                await _RPGCreatedRepository.Create(rpg);
            }
            catch (Exception ex)
            {
                File.WriteAllText("log.txt", ex.Message + " - " + ex.StackTrace);
                throw new Exception("Erro no banco de dados, contate o admnistrador.");
            }
        }
Esempio n. 4
0
 public async Task Update(RPGCreated RPGChanges)
 {
     var rpg = _context.RPGs.Attach(RPGChanges);
     rpg.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Esempio n. 5
0
 public async Task Create(RPGCreated rpg)
 {
     _context.RPGs.Add(rpg);
     await _context.SaveChangesAsync();
 }