Commit bbe48933 authored by Eric Dieckman's avatar Eric Dieckman
Browse files

feat: add RemoveVlanFromLocation endpoint and fix analyzer warnings

parent 6305740b
Loading
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -121,4 +121,24 @@ public class LocationsController : ControllerBase

        return CreatedAtRoute("GetLocationVlanById", new { locationVlanId = mapping.LocationVlanId }, mapping);
    }

    // DELETE: /locations/2/vlans/4
    [Authorize(Policy = Policies.CanEdit)]
    [ProducesResponseType(StatusCodes.Status204NoContent)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    [HttpDelete("{locationId:long}/vlans/{vlanId:long}", Name = "RemoveVlanFromLocation")]
    public async Task<IActionResult> RemoveVlanFromLocationAsync(long locationId, long vlanId)
    {
        LocationVlan? mapping = await _context.LocationVlans
            .Where(lv => lv.LocationId == locationId && lv.VlanId == vlanId)
            .FirstOrDefaultAsync();

        if (mapping == null)
            return NotFound();

        _context.LocationVlans.Remove(mapping);
        await _context.SaveChangesAsync();

        return NoContent();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ public class PaloAltoFirewallsController : ControllerBase
    [HttpGet(Name = "GetAllPaloAltoFirewalls")]
    public async Task<IActionResult> GetAllAsync()
    {
        var result = await _context.PaloAltoFirewalls
        List<PaloAltoFirewall> result = await _context.PaloAltoFirewalls
            .Where(e => e.IsActive == true)
            .ToListAsync();

+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ public class PaloAltoFirewallVlanEntityTypeConfiguration : IEntityTypeConfigurat
        builder.HasOne(e => e.Vlan)
            .WithMany()
            .HasForeignKey(e => e.VlanId);

    }
}
+0 −2
Original line number Diff line number Diff line
@@ -22,6 +22,4 @@ public class PaloAltoFirewallVlan : ICreatedAt, IAuditableEntity

    [JsonIgnore]
    public virtual Vlan? Vlan { get; set; }

}