Skip to content

Commit

Permalink
[Complete] Add new variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nyeinchannmoe committed Aug 18, 2024
1 parent 3bace22 commit c35e00f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions REMS.BackendApi/Features/Agent/AgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,12 @@ public async Task<IActionResult> SearchAgentByNameAndLocation(SearchAgentRequest

return Ok(agentList);
}

[HttpGet("AgentAll", Name = "AgentAll")]
public async Task<IActionResult> AgentAll()
{
Result<List<AgentDto>> agentList = await _blAgent.AgentAll();

return Ok(agentList);
}
}
2 changes: 2 additions & 0 deletions REMS.Models/Appointment/AppointmentDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ namespace REMS.Models.Appointment;

public partial class AppointmentDetail
{
public int? AppointmentId { get; set; }
public string? AgentName { get; set; }
public string? ClientName { get; set; }
public string? AppointmentDate { get; set; }
public string? AppointmentTime { get; set; }
public string? AgentPhoneNumber { get; set; }
public string? Status { get; set; }
public string? Note { get; set; }
public string? Address { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions REMS.Modules/Features/Agent/BL_Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public async Task<Result<AgentListResponseModel>> SearchAgentByNameAndLocationAs
}
return model;
}

public async Task<Result<List<AgentDto>>> AgentAll()
{
return await _daAgent.AgentAllAsync();
}
}
25 changes: 25 additions & 0 deletions REMS.Modules/Features/Agent/DA_Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,29 @@ public async Task<Result<AgentListResponseModel>> SearchAgentByNameAndLocationAs
return model;

}


public async Task<Result<List<AgentDto>>> AgentAllAsync()
{
Result<List<AgentDto>> model = null;
try
{
List<AgentDto> agents = await _db.Agents
.Select(ag => new AgentDto
{
AgentId = ag.AgentId,
UserId = ag.UserId,
AgencyName = ag.AgencyName,
LicenseNumber = ag.LicenseNumber,
Address = ag.Address
})
.ToListAsync();
model = Result<List<AgentDto>>.Success(agents);
}
catch (Exception ex)
{
model = Result<List<AgentDto>>.Error(ex);
}
return model;
}
}
3 changes: 3 additions & 0 deletions REMS.Modules/Features/Appointment/DA_Appointment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ public async Task<Result<AppointmentDetailList>> GetAppointmentByClientId(int cl
join _cli in _db.Clients on _app.ClientId equals _cli.ClientId
join _pro in _db.Properties on _app.PropertyId equals _pro.PropertyId
join _age in _db.Agents on _pro.AgentId equals _age.AgentId
join _user in _db.Users on _age.UserId equals _user.UserId
where _app.ClientId == clientId
select new AppointmentDetail
{
AppointmentId = _app.AppointmentId,
AgentName = _age.AgencyName,
ClientName = _cli.FirstName + " " + _cli.LastName,
AppointmentDate = _app.AppointmentDate.ToString("yyyy-MM-dd"),
AppointmentTime = _app.AppointmentTime.ToString(),
AgentPhoneNumber = _user.Phone,
Status = _app.Status,
Note = _app.Notes,
Address = _pro.Address,
Expand Down

0 comments on commit c35e00f

Please sign in to comment.