Esempio n. 1
0
        public async Task <Mesh> UpdateAsync(Mesh entity)
        {
            var mesh = await VPLContext.Meshes
                       .Include(x => x.Settings)
                       .Where(x => x.Id == entity.Id).SingleOrDefaultAsync();

            mesh.Type = entity.Type;

            VPLContext.Entry(mesh).State = EntityState.Modified;

            try
            {
                await VPLContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MeshExists(mesh.Id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(mesh);
        }
        public async Task <Experiment> UpdateAsync(Experiment entity)
        {
            var experiment = await VPLContext.Experiments
                             .Include(x => x.Meshes)
                             .Include(x => x.Settings)
                             .Include(x => x.CreatedBy)
                             .Where(x => x.Id == entity.Id).SingleOrDefaultAsync();

            experiment.Description = entity.Description;
            experiment.Title       = entity.Title;
            experiment.Name        = entity.Title;
            experiment.Picture     = entity.Picture;

            VPLContext.Entry(experiment).State = EntityState.Modified;

            try
            {
                await VPLContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExperimentExists(experiment.Id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(experiment);
        }
        public async Task <MeshSettings> UpdateAsync(MeshSettings entity)
        {
            VPLContext.Entry(entity).State = EntityState.Modified;

            try
            {
                await VPLContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MeshSettingsExists(entity.Id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(entity);
        }