Joszko
Joszko
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
Ok, found the issue, axios.get is getting the wrong thing because of param
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
that's why i don't like frontend ;.;
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
and thats profile
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
profile: { nickname: 'none', money: 0, energy: 0, rank: 'none', level: 0, experience: 0, levelPoints: 0, healthPoints: 0, attackPoints: 0, defensePoints: 0, luckPoints: 0, intelligencePoints: 0 } };
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
call looks like that
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
async fetchProfile() { try { const response = await axios.get('http://localhost:5033/api/Student/GetStudentProfile', { params: { StudentId: 1 // tutaj ustalamy jakiego uzytkownika id chcemy } }); if (response.data.value.success) { this.profile = response.data.value.data; console.log("Profil:", this.profile); } else { console.error("Failed to fetch profile: ", response.data.value.message); } } catch (error) { console.error("Error fetching profile: ", error); } }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
hmmm, weird cause im using the GetStudentProfile
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
public class GetStudentProfileDTO { public string Nickname { get; set;} = string.Empty; public int Money { get; set; } = 0; public int Energy { get; set; } = 100; public Ranks Rank { get; set; } = Ranks.Silver_I; public int Level { get; set; } = 1; public int Experience { get; set; } = 0; public int LevelPoints { get; set; } = 0; public int HealthPoints { get; set; } = 100; public int AttackPoints { get; set; } = 1; public int DefensePoints { get; set; } = 1; public int LuckPoints { get; set; } = 1; public int IntelligencePoints { get; set; } = 1; }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
i mean, i even showed you output from swagger xD
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
and Dto in swagger looks like it should but idk why it is showing this odd things when consol.logging it in browser
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
it's service call which later im passing to controller: [HttpGet("GetStudentProfile{StudentId}")] public async Task<IActionResult> GetStudentProfile(int StudentId) { return Ok(new JsonResult(await _studentService.GetStudentProfile(StudentId))); }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
public async Task<ServiceResponse<GetStudentProfileDTO>> GetStudentProfile(int StudentId) { var serviceResponse = new ServiceResponse<GetStudentProfileDTO>(); try { var student = await _context.Students .Include(c => c.Account) .FirstOrDefaultAsync(x => x.Id == StudentId); if (student is not null) { GetStudentProfileDTO response = student.Adapt<GetStudentProfileDTO>(); response.Nickname = student.Account.Nickname; serviceResponse.Data = response; } else{ serviceResponse.Success = false; serviceResponse.Message = $"Brak studenta o {StudentId} id"; } } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = $"Error: {ex.Message}"; return serviceResponse; } return serviceResponse; }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
i mean, why account, id or even weapon is showing if it is not in the DTO data
22 replies