Beispiel #1
0
        public async Task <Guid> Create(Models.PartisPJ partPJ)
        {
            try
            {
                var context = CreateContext();
                var created = new Data.PartisPJ
                {
                    PJId        = partPJ.PJId,
                    PartiId     = partPJ.PartiId,
                    Description = partPJ.Description,
                    Id          = partPJ.Id,
                };
                var enr = await context
                          ._PartisPJ
                          .AddAsync(created);

                await context.SaveChangesAsync();

                return(enr.Entity.Id);
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
                return(partPJ.Id);
            }
        }
Beispiel #2
0
        public async Task Delete(Models.PartisPJ partPJ)
        {
            try
            {
                var context  = CreateContext();
                var toDelete = await context._PartisPJ.FindAsync(partPJ.Id);

                if (toDelete != null)
                {
                    context._PartisPJ.Remove(toDelete);
                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #3
0
        public async Task Update(Models.PartisPJ partPJ)
        {
            try
            {
                var context  = CreateContext();
                var toUpdate = await context._PartisPJ.FindAsync(partPJ.Id);

                if (toUpdate != null)
                {
                    toUpdate.PJId        = partPJ.PJId;
                    toUpdate.PartiId     = partPJ.PartiId;
                    toUpdate.Description = partPJ.Description;
                    toUpdate.Id          = partPJ.Id;

                    await context.SaveChangesAsync();
                }
            }
            catch (DbUpdateException e)
            {
                Console.WriteLine(e.Message);
            }
        }