Skip to content

Commit

Permalink
Backup Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
neojarvis committed Sep 25, 2023
1 parent 541e21c commit b7f79e2
Show file tree
Hide file tree
Showing 77 changed files with 1,223 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
using dotnetmicroservicetwo.Models;

namespace dotnetmicroservicetwo.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ChannelController : ControllerBase
{
private readonly ChannelDbContext _context;

public ChannelController(ChannelDbContext context)
{
_context = context;
}

[HttpGet]
public async Task<ActionResult<IEnumerable<Channel>>> GetAllChannels()
{
var channels = await _context.Channels.ToListAsync();
return Ok(channels);
}
[HttpGet("ChannelNames")]
public async Task<ActionResult<IEnumerable<string>>> Get()
{
// Project the ChannelTitle property using Select
var ChannelNames = await _context.Channels
.OrderBy(x => x.ChannelName)
.Select(x => x.ChannelName)
.ToListAsync();

return ChannelNames;
}
[HttpPost]
public async Task<ActionResult> AddChannel(Channel channel)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState); // Return detailed validation errors
}
await _context.Channels.AddAsync(channel);
await _context.SaveChangesAsync();
return Ok();
}
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteChannel(int id)
{
if (id <= 0)
return BadRequest("Not a valid Channel id");

var channel = await _context.Channels.FindAsync(id);
_context.Channels.Remove(channel);
await _context.SaveChangesAsync();
return NoContent();
}
}
}
18 changes: 18 additions & 0 deletions dotnetproject/dotnetmicroservicetwo/Models/Channel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;

namespace dotnetmicroservicetwo.Models;
public class Channel
{
public int ChannelID { get; set; }

public string? ChannelName { get; set; }

public string? POCName { get; set; }

public decimal? CommercialPerAd { get; set; }

public string? MailID { get; set; }
public string? ContactNumber { get; set; }

}
15 changes: 15 additions & 0 deletions dotnetproject/dotnetmicroservicetwo/Models/ChannelDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace dotnetmicroservicetwo.Models;

public class ChannelDbContext : DbContext
{

public ChannelDbContext(DbContextOptions<ChannelDbContext> options)
: base(options)
{
}
public virtual DbSet<Channel> Channels { get; set; }
}
11 changes: 0 additions & 11 deletions dotnetproject/dotnetmicroservicetwo/Models/Song.cs

This file was deleted.

21 changes: 0 additions & 21 deletions dotnetproject/dotnetmicroservicetwo/Models/SongDbContext.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7277;http://localhost:5202",
"applicationUrl": "https://0.0.0.0:8081",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
5 changes: 4 additions & 1 deletion dotnetproject/dotnetmicroservicetwo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
"MyConnString":"User ID=sa;password=examlyMssql@123;server=localhost;Database=ChannelsDB;trusted_connection=false;Persist Security Info=False;Encrypt=False;"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit b7f79e2

Please sign in to comment.