Esempio n. 1
0
        public async Task Update(Models.BgPJ bgpj)
        {
            try
            {
                var context  = CreateContext();
                var toUpdate = await context._BgPJ.FindAsync(bgpj.Id);

                if (toUpdate != null)
                {
                    toUpdate.Id           = bgpj.Id;
                    toUpdate.PJId         = bgpj.PJId;
                    toUpdate.Ordre        = bgpj.Ordre;
                    toUpdate.PersoBgId    = bgpj.PersoBgId;
                    toUpdate.RelationBgId = bgpj.RelationBgId;
                    toUpdate.PartisBgId   = bgpj.PartisBgId;
                    toUpdate.ChronoPJId   = bgpj.ChronoPJId;

                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 2
0
        public async Task <Guid> Create(Models.BgPJ bgpj)
        {
            try
            {
                var context = CreateContext();
                var created = new Data.BgPJ
                {
                    Id           = bgpj.Id,
                    PJId         = bgpj.PJId,
                    Ordre        = bgpj.Ordre,
                    PersoBgId    = bgpj.PersoBgId,
                    RelationBgId = bgpj.RelationBgId,
                    PartisBgId   = bgpj.PartisBgId,
                    ChronoPJId   = bgpj.ChronoPJId,
                };
                var enr = await context
                          ._BgPJ
                          .AddAsync(created);

                await context.SaveChangesAsync();

                return(enr.Entity.Id);
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
                return(bgpj.Id);
            }
        }
Esempio n. 3
0
        public async Task Delete(Models.BgPJ bgpj)
        {
            try
            {
                var context  = CreateContext();
                var toDelete = await context._BgPJ.FindAsync(bgpj.Id);

                if (toDelete != null)
                {
                    context._BgPJ.Remove(toDelete);
                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
            }
        }