Exemplo n.º 1
0
        public void Remove(Device device)
        {
            var model      = DeviceModel.FromRepositoryType(device);
            var sql        = @"
                DELETE
                FROM DeviceModels
                WHERE Id = @Id
            ";
            var parameters = new
            {
                Id = model.Id,
            };

            _connection.Execute(sql, parameters);
        }
Exemplo n.º 2
0
        public void Add(Device device)
        {
            var model      = DeviceModel.FromRepositoryType(device);
            var sql        = @"
                INSERT INTO DeviceModels
                (
                  Address,
                  IsConnected,
                  LastPing,
                  Name,
                  Network_Id,
                  Notes,
                  Type_Name
                )
                VALUES
                (
                  @Address,
                  @IsConnected,
                  @LastPing,
                  @Name,
                  @Network_Id,
                  @Notes,
                  @Type_Name
                )
                
                SELECT CAST(IDENT_CURRENT('DeviceModels') as int)
            ";
            var parameters = new
            {
                Address     = model.Address,
                IsConnected = model.IsConnected,
                LastPing    = model.LastPing,
                Name        = model.LastPing,
                Network_Id  = model.Network_Id,
                Notes       = model.Notes,
                Type_Name   = model.Type_Name,
            };

            var id = _connection.QuerySingle <int>(sql, parameters);

            device.SetId(id);
        }
Exemplo n.º 3
0
        public void Update(Device device)
        {
            var model      = DeviceModel.FromRepositoryType(device);
            var sql        = @"
                UPDATE DeviceModels
                SET
                  Name = @Name,
                  Notes = @Notes,
                  Type_Name = @Type_Name
                WHERE Id = @Id
            ";
            var parameters = new
            {
                Id        = model.Id,
                Name      = model.Name,
                Notes     = model.Notes,
                Type_Name = model.Type_Name,
            };

            _connection.Execute(sql, parameters);
        }