Commit 50a4695a authored by Eric Dieckman's avatar Eric Dieckman
Browse files

Add vlan use types

parent 2e087e82
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ public class VlansController : ControllerBase

    public VlansController(ApplicationDbContext context) => _context = context;

    // GET: /api/vlans
    // GET: /vlans
    [ProducesResponseType<Vlan>(StatusCodes.Status200OK)]
    [HttpGet(Name = "GetAllVlans")]
    public async Task<IActionResult> GetAllAsync()
@@ -24,7 +24,7 @@ public class VlansController : ControllerBase
        return Ok(result);
    }

    // GET: /api/vlans/1
    // GET: /vlans/1
    [ProducesResponseType<Vlan>(StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    [HttpGet("{vlanId:long}", Name = "GetVlanById")]
@@ -40,7 +40,7 @@ public class VlansController : ControllerBase
        return Ok(result);
    }

    // POST: /api/vlans
    // POST: /vlans
    [ProducesResponseType<Vlan>(StatusCodes.Status201Created)]
    [HttpPost(Name = "CreateNewVlan")]
    public async Task<IActionResult> CreateNewAsync([FromBody] Vlan data)
@@ -51,7 +51,7 @@ public class VlansController : ControllerBase
        return CreatedAtAction(nameof(GetByIdAsync), new { vlanId = data.VlanId }, data);
    }

    // PUT: /api/vlans/2
    // PUT: /vlans/2
    [ProducesResponseType<Vlan>(StatusCodes.Status200OK)]
    [HttpPut("{vlanId:long}", Name = "UpdateVlan")]
    public async Task<IActionResult> UpdateAsync(long vlanId, [FromBody] Vlan data)
@@ -75,4 +75,19 @@ public class VlansController : ControllerBase

        return Ok(entity);
    }
    // ######################################################
    // ### VLAN USE TYPES
    //

    // GET: /vlans/usetypes
    [ProducesResponseType<IEnumerable<VlanUseType>>(StatusCodes.Status200OK)]
    [HttpGet("use_types", Name = "VlansUseTypes_GetAll")]
    public async Task<IActionResult> GetUseTypesAsync()
    {
        List<VlanUseType> result = await _context.VlanUseTypes
            .Where(e => e.IsActive == true)
            .ToListAsync();

        return Ok(result);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ public class ApplicationDbContext : DbContext
    public DbSet<LocationVlan> LocationVlans => Set<LocationVlan>();
    public DbSet<PaloAltoAccessDomain> PaloAltoAccessDomains => Set<PaloAltoAccessDomain>();
    public DbSet<Vlan> Vlans => Set<Vlan>();
    public DbSet<VlanUseType> VlanUseTypes => Set<VlanUseType>();
    public DbSet<PaloAltoVsys> PaloAltoVsyses => Set<PaloAltoVsys>();
    public DbSet<WiscNicGroup> WiscNicGroups => Set<WiscNicGroup>();
    public DbSet<WiscNicGroupMembershipType> WiscNicGroupMembershipTypes => Set<WiscNicGroupMembershipType>();
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ internal sealed class ColumnNames
    internal const string LocationVlanId = "location_vlan_id";
    internal const string AreaId = "area_id";
    internal const string PersonId = "person_id";
    internal const string VlanUseTypeId = "vlan_use_type_id";

    internal sealed class PaloAlto
    {
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ internal sealed class TableNames
    internal const string People = "people";
    internal const string Subnets = "subnets";
    internal const string Vlans = "vlans";
    internal const string VlanUseTypes = "vlan_use_types";
    internal const string WiscNicGroupMembers = "wn_group_members";
    internal const string WiscNicGroupMembershipTypes = "wn_group_membership_types";
    internal const string WiscNicGroups = "wn_groups";
+7 −0
Original line number Diff line number Diff line
@@ -23,9 +23,16 @@ public class VlanEntityTypeConfiguration : IEntityTypeConfiguration<Vlan>
        builder.Property(e => e.AreaId)
            .HasColumnName(ColumnNames.AreaId);

        builder.Property(e => e.VlanUseTypeId)
            .HasColumnName(ColumnNames.VlanUseTypeId);

        builder.HasOne(e => e.Area)
            .WithMany()
            .HasForeignKey(e => e.AreaId);

        builder.HasOne(e => e.UseType)
            .WithMany()
            .HasForeignKey(e => e.VlanUseTypeId);
    }
}
Loading