From c35e00f26489ba8a21d15e5001d6fe1a28ee2194 Mon Sep 17 00:00:00 2001 From: Nyein Chann Moe Date: Sun, 18 Aug 2024 17:05:52 +0630 Subject: [PATCH] [Complete] Add new variables --- .../Features/Agent/AgentController.cs | 8 ++++++ REMS.Models/Appointment/AppointmentDetail.cs | 2 ++ REMS.Modules/Features/Agent/BL_Agent.cs | 5 ++++ REMS.Modules/Features/Agent/DA_Agent.cs | 25 +++++++++++++++++++ .../Features/Appointment/DA_Appointment.cs | 3 +++ 5 files changed, 43 insertions(+) diff --git a/REMS.BackendApi/Features/Agent/AgentController.cs b/REMS.BackendApi/Features/Agent/AgentController.cs index 80dd873..7329ced 100644 --- a/REMS.BackendApi/Features/Agent/AgentController.cs +++ b/REMS.BackendApi/Features/Agent/AgentController.cs @@ -88,4 +88,12 @@ public async Task SearchAgentByNameAndLocation(SearchAgentRequest return Ok(agentList); } + + [HttpGet("AgentAll", Name = "AgentAll")] + public async Task AgentAll() + { + Result> agentList = await _blAgent.AgentAll(); + + return Ok(agentList); + } } \ No newline at end of file diff --git a/REMS.Models/Appointment/AppointmentDetail.cs b/REMS.Models/Appointment/AppointmentDetail.cs index 3f8de49..708a123 100644 --- a/REMS.Models/Appointment/AppointmentDetail.cs +++ b/REMS.Models/Appointment/AppointmentDetail.cs @@ -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; } diff --git a/REMS.Modules/Features/Agent/BL_Agent.cs b/REMS.Modules/Features/Agent/BL_Agent.cs index 5f47437..06e538b 100644 --- a/REMS.Modules/Features/Agent/BL_Agent.cs +++ b/REMS.Modules/Features/Agent/BL_Agent.cs @@ -60,4 +60,9 @@ public async Task> SearchAgentByNameAndLocationAs } return model; } + + public async Task>> AgentAll() + { + return await _daAgent.AgentAllAsync(); + } } \ No newline at end of file diff --git a/REMS.Modules/Features/Agent/DA_Agent.cs b/REMS.Modules/Features/Agent/DA_Agent.cs index a1296ee..67401b2 100644 --- a/REMS.Modules/Features/Agent/DA_Agent.cs +++ b/REMS.Modules/Features/Agent/DA_Agent.cs @@ -304,4 +304,29 @@ public async Task> SearchAgentByNameAndLocationAs return model; } + + + public async Task>> AgentAllAsync() + { + Result> model = null; + try + { + List 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>.Success(agents); + } + catch (Exception ex) + { + model = Result>.Error(ex); + } + return model; + } } \ No newline at end of file diff --git a/REMS.Modules/Features/Appointment/DA_Appointment.cs b/REMS.Modules/Features/Appointment/DA_Appointment.cs index e9289a3..006c4df 100644 --- a/REMS.Modules/Features/Appointment/DA_Appointment.cs +++ b/REMS.Modules/Features/Appointment/DA_Appointment.cs @@ -189,13 +189,16 @@ public async Task> 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,