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); } }
public async Task <EntityState> Create(Device device) { var deviceEntityState = _context.Entry(device).State = EntityState.Added; await _context.SaveChangesAsync(); return(deviceEntityState); }
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); } }