-
Notifications
You must be signed in to change notification settings - Fork 0
branch update #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
branch update #68
Changes from all commits
4736924
1111c66
b940679
46c8895
27b5bd8
15ab2e6
4927254
8e025f8
6c30361
687627e
02b398e
b9fc45c
ace8530
60cd751
93cf194
dbb096d
e1d408d
8170fee
3788d84
2a30e78
abf7138
33c5da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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 | ||
| { | ||
| 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) | ||
|
||
| { | ||
| 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."); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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}"))}"); | ||||||
|
||||||
| 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
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
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.