Exemplo n.º 1
0
        public async Task Delete(Models.Pays ppays)
        {
            try
            {
                var context  = CreateContext();
                var toDelete = await context._Pays.FindAsync(ppays.Id);

                if (toDelete != null)
                {
                    context._Pays.Remove(toDelete);
                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 2
0
        public async Task <Guid> Create(Models.Pays ppays)
        {
            try
            {
                var context = CreateContext();
                var created = new Data.Pays
                {
                    Id      = ppays.Id,
                    NomPays = ppays.NomPays,
                };
                var enr = await context
                          ._Pays
                          .AddAsync(created);

                await context.SaveChangesAsync();

                return(enr.Entity.Id);
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
                return(ppays.Id);
            }
        }