コード例 #1
0
        public async Task <int?> Upsert(Job job)
        {
            try
            {
                foreach (var telemData in job.TelemData.ToList())
                {
                    await _context.TelemData.AddAsync(telemData);
                }

                if (job.Id == 0)
                {
                    await _context.Job.AddAsync(job);
                }
                else
                {
                    _context.Job.Update(job);
                }

                _context.Entry(job.Device).State = EntityState.Unchanged;

                await _context.SaveChangesAsync();

                return(job.Id);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #2
0
        public async Task <EntityState> Create(Device device)
        {
            var deviceEntityState = _context.Entry(device).State = EntityState.Added;

            await _context.SaveChangesAsync();

            return(deviceEntityState);
        }
コード例 #3
0
        public async Task <EntityState> Create(User user)
        {
            try
            {
                var userEntityState = _context.Entry(user).State = EntityState.Added;

                await _context.SaveChangesAsync();

                return(userEntityState);
            }
            catch
            {
                return(EntityState.Unchanged);
            }
        }