Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4736924
Merge pull request #51 from rithakith/main
JalinaH May 27, 2025
1111c66
Merge pull request #53 from rithakith/main
JalinaH May 27, 2025
b940679
Fix user initialization check in DbInitializer to prevent unnecessary…
VishwaJaya01 Jul 18, 2025
46c8895
Merge remote-tracking branch 'origin/main' into dev-jayasankha
VishwaJaya01 Jul 18, 2025
27b5bd8
Merge pull request #59 from rithakith/dev-akith
rithakith Jul 18, 2025
15ab2e6
Merge pull request #60 from rithakith/dev-jayasankha
rithakith Jul 18, 2025
4927254
Add sorting and search functionality to LAMasterfile endpoints and mo…
VishwaJaya01 Jul 19, 2025
8e025f8
Merge pull request #61 from rithakith/main
JalinaH Jul 19, 2025
6c30361
Merge branch 'main' into dev-jayasankha
VishwaJaya01 Jul 19, 2025
687627e
Add authorization attribute to ConditionReportController and update H…
JalinaH Jul 19, 2025
02b398e
Enhance UploadImages method to accept parent_id and parent_type param…
VishwaJaya01 Jul 19, 2025
b9fc45c
Add [Authorize] attribute to BuildingRatesLA, PastValuationsLA, Renta…
JalinaH Jul 20, 2025
ace8530
Refactor ImageData and SendImageDataRequest to use int for ReportId; …
VishwaJaya01 Jul 20, 2025
60cd751
Merge pull request #62 from rithakith/dev-jayasankha
rithakith Jul 20, 2025
93cf194
Merge pull request #63 from rithakith/dev-jalina
rithakith Jul 20, 2025
dbb096d
Add assignedToUserId parameter to LAMasterfile methods for user-speci…
VishwaJaya01 Jul 20, 2025
e1d408d
deploy.yml create
rithakith Jul 20, 2025
8170fee
Add ProfilePicture field to User model and update migrations
VishwaJaya01 Jul 20, 2025
3788d84
Merge branch 'main' into dev-jayasankha
VishwaJaya01 Jul 20, 2025
2a30e78
Merge pull request #65 from rithakith/dev-jayasankha
rithakith Jul 20, 2025
abf7138
Enhance UserTaskController to include detailed task type counts and i…
VishwaJaya01 Jul 20, 2025
33c5da5
Merge pull request #67 from rithakith/dev-jayasankha
rithakith Jul 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy to EC2
on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: SSH and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
script: |
cd /home/ec2-user/ValuationBackend
git pull
dotnet restore
sudo dotnet publish -c Release -o /var/app
sudo systemctl restart valuation-backend
2 changes: 2 additions & 0 deletions Controllers/BuildingRatesLAController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand All @@ -6,6 +7,7 @@

namespace ValuationBackend.Controllers
{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class BuildingRatesLAController : ControllerBase
Expand Down
2 changes: 2 additions & 0 deletions Controllers/ConditionReportController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand All @@ -6,6 +7,7 @@

namespace ValuationBackend.Controllers
{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class ConditionReportController : ControllerBase
Expand Down
6 changes: 3 additions & 3 deletions Controllers/ImageDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ImageDataController(AppDbContext context)
[HttpPost]
public IActionResult SendImageData([FromBody] SendImageDataRequest request)
{
if (string.IsNullOrWhiteSpace(request.ReportId) || request.Images == null || !request.Images.Any())
if (request.ReportId <= 0 || request.Images == null || !request.Images.Any())
{
return BadRequest("Missing reportId or images.");
}
Expand All @@ -38,9 +38,9 @@ public IActionResult SendImageData([FromBody] SendImageDataRequest request)

// ✅ 2. Accept actual image files via form-data
[HttpPost("upload")]
public async Task<IActionResult> UploadImages([FromForm] string reportId, [FromForm] List<IFormFile> files)
public async Task<IActionResult> UploadImages([FromForm] int reportId, [FromForm] List<IFormFile> files)
{
if (string.IsNullOrWhiteSpace(reportId) || files == null || !files.Any())
if (reportId <= 0 || files == null || !files.Any())
return BadRequest("Missing reportId or files.");

foreach (var file in files)
Expand Down
16 changes: 8 additions & 8 deletions Controllers/LAMasterfileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ public LAMasterfileController(ILAMasterfileService service)
}

[HttpGet]
public ActionResult<LAMasterfileResponse> GetAll([FromQuery] int pageNumber = 0, [FromQuery] int pageSize = 15)
public ActionResult<LAMasterfileResponse> GetAll([FromQuery] int pageNumber = 0, [FromQuery] int pageSize = 15, [FromQuery] string sortBy = "", [FromQuery] int? assignedToUserId = null)
{
// Adjust pageNumber to be 1-based for internal logic
var page = pageNumber + 1;
return Ok(_service.GetPaged(page, pageSize));
return Ok(_service.GetPaged(page, pageSize, sortBy, assignedToUserId));
}

[HttpGet("paged")]
public ActionResult<LAMasterfileResponse> GetPaged([FromQuery] int page = 1, [FromQuery] int pageSize = 10)
public ActionResult<LAMasterfileResponse> GetPaged([FromQuery] int page = 1, [FromQuery] int pageSize = 10, [FromQuery] string sortBy = "", [FromQuery] int? assignedToUserId = null)
{
return Ok(_service.GetPaged(page, pageSize));
return Ok(_service.GetPaged(page, pageSize, sortBy, assignedToUserId));
}

[HttpPost("search")]
[HttpPost("filter")]
public ActionResult<LAMasterfileResponse> Search([FromBody] LAQueryRequest request)
public ActionResult<LAMasterfileResponse> Search([FromBody] LAQueryRequest request, [FromQuery] string sortBy = "", [FromQuery] int? assignedToUserId = null)
{
var query = request.Query.ToLower();
var response = _service.Search(query);
var response = _service.Search(query, sortBy, assignedToUserId);
return Ok(response);
}

[HttpPost("search/paged")]
public ActionResult<LAMasterfileResponse> SearchPaged([FromBody] LAQueryRequest request, [FromQuery] int page = 1, [FromQuery] int pageSize = 10)
public ActionResult<LAMasterfileResponse> SearchPaged([FromBody] LAQueryRequest request, [FromQuery] int page = 1, [FromQuery] int pageSize = 10, [FromQuery] string sortBy = "", [FromQuery] int? assignedToUserId = null)
{
var query = request.Query.ToLower();
var response = _service.SearchPaged(query, page, pageSize);
var response = _service.SearchPaged(query, page, pageSize, sortBy, assignedToUserId);
return Ok(response);
}
}
Expand Down
2 changes: 2 additions & 0 deletions Controllers/PastValuationsLAController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
Expand All @@ -7,6 +8,7 @@

namespace ValuationBackend.Controllers
{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class PastValuationsLAController : ControllerBase
Expand Down
3 changes: 2 additions & 1 deletion Controllers/ProfileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public IActionResult GetUserProfile([FromBody] UserProfileRequest request)
empEmail = user.EmpEmail,
empId = user.EmpId,
position = user.Position,
assignedDivision = user.AssignedDivision
assignedDivision = user.AssignedDivision,
profilePicture = user.ProfilePicture != null ? Convert.ToBase64String(user.ProfilePicture) : null
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions Controllers/RentalEvidenceLAController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
Expand All @@ -7,6 +8,7 @@

namespace ValuationBackend.Controllers
{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class RentalEvidenceLAController : ControllerBase
Expand Down
2 changes: 2 additions & 0 deletions Controllers/SalesEvidenceLAController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
Expand All @@ -7,6 +8,7 @@

namespace ValuationBackend.Controllers
{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class SalesEvidenceLAController : ControllerBase
Expand Down
43 changes: 43 additions & 0 deletions Controllers/UserProfileController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ValuationBackend.Data;

namespace ValuationBackend.Controllers
{
public class ProfilePictureUploadDto
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The DTO class is defined inside the controller file. DTOs should be placed in a separate Models or DTOs folder for better organization and reusability.

Copilot uses AI. Check for mistakes.
{
public int UserId { get; set; }
public IFormFile Image { get; set; }
}

[ApiController]
[Route("api/[controller]")]
public class UserProfileController : ControllerBase
{
private readonly AppDbContext _context;

public UserProfileController(AppDbContext context)
{
_context = context;
}

[HttpPost("upload-profile-picture")]
public async Task<IActionResult> UploadProfilePicture([FromForm] ProfilePictureUploadDto dto)
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The profile picture upload endpoint lacks file validation for size limits, file type restrictions, and malicious content checks. This could allow users to upload large files or potentially harmful content.

Copilot uses AI. Check for mistakes.
{
if (dto.Image == null || dto.Image.Length == 0)
return BadRequest("No image uploaded.");

var user = await _context.Users.FirstOrDefaultAsync(u => u.Id == dto.UserId);
if (user == null)
return NotFound("User not found.");

using var ms = new MemoryStream();
await dto.Image.CopyToAsync(ms);
user.ProfilePicture = ms.ToArray();

await _context.SaveChangesAsync();

return Ok("Profile picture updated.");
}
}
}
18 changes: 12 additions & 6 deletions Controllers/UserTaskController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ public ActionResult<UserTaskOverviewResponse> GetTaskOverview([FromBody] UserTas
{
var userTasks = _context.UserTasks.Where(t => t.Username == request.Username).ToList();

var laAssigned = userTasks.Count(t => t.TaskType == "LA");
var laCompleted = userTasks.Count(t => t.TaskType == "LA" && t.IsCompleted);
var mrAssigned = userTasks.Count(t => t.TaskType == "MR");
var mrCompleted = userTasks.Count(t => t.TaskType == "MR" && t.IsCompleted);
var lmAssigned = userTasks.Count(t => t.TaskType == "LM");
var lmCompleted = userTasks.Count(t => t.TaskType == "LM" && t.IsCompleted);
// Debug log: print all userTasks for this user
Console.WriteLine($"UserTasks for {request.Username}: {string.Join(", ", userTasks.Select(t => $"{t.TaskType}:{t.IsCompleted}"))}");
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console output should not be present in production code. Use proper logging frameworks like ILogger instead of Console.WriteLine for debugging purposes.

Suggested change
Console.WriteLine($"UserTasks for {request.Username}: {string.Join(", ", userTasks.Select(t => $"{t.TaskType}:{t.IsCompleted}"))}");
_logger.LogInformation("UserTasks for {Username}: {UserTasks}", request.Username, string.Join(", ", userTasks.Select(t => $"{t.TaskType}:{t.IsCompleted}")));

Copilot uses AI. Check for mistakes.

var laAssigned = userTasks.Count(t => t.TaskType != null && t.TaskType.ToUpper() == "LA");
var laCompleted = userTasks.Count(t => t.TaskType != null && t.TaskType.ToUpper() == "LA" && t.IsCompleted);
var mrAssigned = userTasks.Count(t => t.TaskType != null && t.TaskType.ToUpper() == "MR");
var mrCompleted = userTasks.Count(t => t.TaskType != null && t.TaskType.ToUpper() == "MR" && t.IsCompleted);
var lmAssigned = userTasks.Count(t => t.TaskType != null && t.TaskType.ToUpper() == "LM");
var lmCompleted = userTasks.Count(t => t.TaskType != null && t.TaskType.ToUpper() == "LM" && t.IsCompleted);

// Debug log: print computed counts
Console.WriteLine($"LA: {laAssigned}, MR: {mrAssigned}, LM: {lmAssigned}, LA Done: {laCompleted}, MR Done: {mrCompleted}, LM Done: {lmCompleted}");
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console output should not be present in production code. Use proper logging frameworks like ILogger instead of Console.WriteLine for debugging purposes.

Suggested change
Console.WriteLine($"LA: {laAssigned}, MR: {mrAssigned}, LM: {lmAssigned}, LA Done: {laCompleted}, MR Done: {mrCompleted}, LM Done: {lmCompleted}");
_logger.LogDebug("LA: {LaAssigned}, MR: {MrAssigned}, LM: {LmAssigned}, LA Done: {LaCompleted}, MR Done: {MrCompleted}, LM Done: {LmCompleted}", laAssigned, mrAssigned, lmAssigned, laCompleted, mrCompleted, lmCompleted);

Copilot uses AI. Check for mistakes.

return Ok(new UserTaskOverviewResponse
{
Expand Down
4 changes: 2 additions & 2 deletions Data/DBInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Initialize(AppDbContext context)
UpdateUserTaskUserIds(context);

// Remove UserTasks that are not LM (Land Miscellaneous)
RemoveNonLMUserTasks(context);
// RemoveNonLMUserTasks(context);

// Initialize Master Data
InitializeMasterData(context); // Initialize Land Aquisition Master Files
Expand Down Expand Up @@ -1048,7 +1048,7 @@ private static void InitializeReports(AppDbContext context)

private static void InitializeUsers(AppDbContext context)
{
//if (context.Users.Any()) return;
if (context.Users.Any()) return;

Console.WriteLine("Seeding users...");

Expand Down
Loading