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

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

                await context.SaveChangesAsync();

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