예제 #1
0
        public async Task CreateAsync(Device device)
        {
            _context.Attach(device);
            _context.Entry(device).State = EntityState.Added;
            await _context.SaveChangesAsync();

            _context.Entry(device).State = EntityState.Detached;
        }
예제 #2
0
        public async Task CreateAsync(string sensorId, int deviceId)
        {
            var sensorDevice = new SensorDevice
            {
                DeviceId = deviceId,
                SensorId = sensorId
            };

            _context.Attach(sensorDevice);
            _context.Entry(sensorDevice).State = EntityState.Added;
            await _context.SaveChangesAsync();

            _context.Entry(sensorDevice).State = EntityState.Detached;
        }
예제 #3
0
        public async Task CreateAsync(string sensorId, int labelNumber, double match)
        {
            var soundLog = new RecognizedSoundLog
            {
                LabelNumber  = labelNumber,
                Match        = match,
                SensorId     = sensorId,
                CreationDate = DateTime.UtcNow
            };

            _context.Attach(soundLog);
            _context.Entry(soundLog).State = EntityState.Added;
            await _context.SaveChangesAsync();

            _context.Entry(soundLog).State = EntityState.Detached;
        }
예제 #4
0
        public async Task <IdentityResult> CreateAsync(ApplicationUser user, CancellationToken cancellationToken)
        {
            try
            {
                await _context.ApplicationUser.AddAsync(user, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                _context.Entry(user).State = EntityState.Detached;
                return(IdentityResult.Success);
            }
            catch
            {
                return(IdentityResult.Failed(new IdentityError
                {
                    Description = "Não foi possível inserir o usuário"
                }));
            }
        }