Skip to content

Commit e9d35b8

Browse files
authored
Merge pull request #79 from rithakith/dev-dulmini
Dev dulmini
2 parents 61fbd09 + 8a4e976 commit e9d35b8

12 files changed

Lines changed: 172 additions & 2 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using ValuationBackend.Models.DTOs;
5+
using ValuationBackend.Services;
6+
using ValuationBackend.Data;
7+
using ValuationBackend.Models;
8+
using Microsoft.EntityFrameworkCore;
9+
10+
11+
[ApiController]
12+
[Route("api/decision-fields")]
13+
public class DecisionFieldController : ControllerBase
14+
{
15+
private readonly ValuationContext _context;
16+
17+
public DecisionFieldController(ValuationContext context)
18+
{
19+
_context = context;
20+
}
21+
22+
[HttpPost]
23+
public async Task<IActionResult> CreateField([FromBody] DecisionField field)
24+
{
25+
_context.DecisionFields.Add(field);
26+
await _context.SaveChangesAsync();
27+
return Ok(field);
28+
}
29+
30+
[HttpGet]
31+
public async Task<IActionResult> GetAllFields()
32+
{
33+
var fields = await _context.DecisionFields.ToListAsync();
34+
return Ok(fields);
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
[ApiController]
4+
[Route("api/{requestType}/ratingfile")]
5+
public class RatingFileController : ControllerBase
6+
{
7+
// 1. Load all street names
8+
[HttpGet("streets")]
9+
public IActionResult GetStreets(string requestType)
10+
{
11+
var streets = new[]
12+
{
13+
new { id = "S1", name = "Main Street" },
14+
new { id = "S2", name = "Highway Road" },
15+
new { id = "S3", name = "Park Avenue" }
16+
};
17+
18+
return Ok(new { streets });
19+
}
20+
21+
// 2. Load obsolete numbers for selected street
22+
[HttpGet("streets/{streetId}/obsolete-numbers")]
23+
public IActionResult GetObsoleteNumbers(string requestType, string streetId)
24+
{
25+
var obsoleteNumbers = new[]
26+
{
27+
new { id = "O1", number = "101" },
28+
new { id = "O2", number = "102" },
29+
new { id = "O3", number = "103" }
30+
};
31+
32+
return Ok(new { obsoleteNumbers });
33+
}
34+
}

Data/AppDbContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public AppDbContext(DbContextOptions<AppDbContext> options)
1010
: base(options) { }
1111

1212
public DbSet<RatingRequest> RatingRequests { get; set; }
13-
13+
1414
public DbSet<LandMiscellaneousMasterFile> LandMiscellaneousMasterFiles { get; set; }
1515

1616
public DbSet<Reconciliation> Reconciliations { get; set; }
@@ -62,6 +62,8 @@ public AppDbContext(DbContextOptions<AppDbContext> options)
6262

6363
public DbSet<PropertyCategory> PropertyCategories { get; set; }
6464

65+
66+
public DbSet<DecisionField> DecisionFields { get; set; }
6567
public DbSet<PasswordReset> PasswordResets { get; set; }
6668

6769
protected override void OnModelCreating(ModelBuilder modelBuilder)

Data/DBInitializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,5 +1913,7 @@ private static void InitializeReconciliations(AppDbContext context)
19131913
context.SaveChanges();
19141914
Console.WriteLine("Reconciliations seeded.");
19151915
}
1916+
1917+
19161918
}
19171919
}

Data/ValuationContext.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using ValuationBackend.Models;
3+
4+
namespace ValuationBackend.Data
5+
{
6+
public class ValuationContext : DbContext
7+
{
8+
public ValuationContext(DbContextOptions<ValuationContext> options) : base(options) { }
9+
10+
public DbSet<DecisionField> DecisionFields { get; set; }
11+
// ...add other DbSets as needed...
12+
}
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class ObsoleteNumberDto
2+
{
3+
public string Id { get; set; }
4+
public string Number { get; set; }
5+
}

Models/iteration2/DTOs/streets.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class StreetDto
2+
{
3+
public string Id { get; set; }
4+
public string Name { get; set; }
5+
}

Models/iteration2/Decision.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class DecisionField
2+
{
3+
public int Id { get; set; }
4+
public string Field { get; set; } // E.g., "Zone"
5+
public string FieldDescription { get; set; } // E.g., "Zoning Category"
6+
public string FieldType { get; set; } // E.g., "string", "number"
7+
public int FieldSize { get; set; } // E.g., 255
8+
}

Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
options.ExpiryMinutes = jwtSettings.ExpiryMinutes;
6969
});
7070

71+
builder.Services.AddDbContext<ValuationContext>(options =>
72+
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
73+
74+
7175
// Add Authentication
7276
var key = Encoding.UTF8.GetBytes(jwtSettings.SecretKey);
7377
builder.Services.AddAuthentication(options =>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Microsoft.EntityFrameworkCore;
4+
using ValuationBackend.Data;
5+
using ValuationBackend.Models;
6+
7+
namespace ValuationBackend.Repositories
8+
{
9+
public class DecisionFieldRepository
10+
{
11+
private readonly ValuationContext _context;
12+
13+
public DecisionFieldRepository(ValuationContext context)
14+
{
15+
_context = context;
16+
}
17+
18+
public async Task<IEnumerable<DecisionField>> GetAllAsync()
19+
{
20+
return await _context.DecisionFields.ToListAsync();
21+
}
22+
23+
public async Task<DecisionField> AddAsync(DecisionField field)
24+
{
25+
_context.DecisionFields.Add(field);
26+
await _context.SaveChangesAsync();
27+
return field;
28+
}
29+
30+
// Add more methods as needed (e.g., GetByIdAsync, UpdateAsync, DeleteAsync)
31+
}
32+
}

0 commit comments

Comments
 (0)