fix: consultation notifications, profile edit hint, doctor report in Chinese, chat UI polish, tabbar badge
This commit is contained in:
@@ -59,6 +59,30 @@ public class ConsultationService(AppDbContext db)
|
||||
ImageUrl = imageUrl,
|
||||
};
|
||||
db.ConsultationMessages.Add(message);
|
||||
|
||||
// Create notification for the recipient
|
||||
var consultation = await db.Consultations
|
||||
.Include(c => c.Patient)
|
||||
.Include(c => c.Doctor)
|
||||
.FirstOrDefaultAsync(c => c.Id == consultationId);
|
||||
|
||||
if (consultation != null)
|
||||
{
|
||||
var targetUserId = senderRole == "patient" ? consultation.DoctorId : consultation.PatientId;
|
||||
var senderName = senderRole == "patient" ? consultation.Patient?.Name : consultation.Doctor?.Name;
|
||||
var notifyTitle = senderRole == "patient" ? "新患者消息" : "医生已回复";
|
||||
var notifyContent = $"{senderName ?? "对方"}:{TruncateContent(content)}";
|
||||
|
||||
db.Notifications.Add(new Notification
|
||||
{
|
||||
UserId = targetUserId,
|
||||
Type = "consultation",
|
||||
Title = notifyTitle,
|
||||
Content = notifyContent,
|
||||
RelatedId = consultationId,
|
||||
});
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
return message;
|
||||
}
|
||||
@@ -70,4 +94,7 @@ public class ConsultationService(AppDbContext db)
|
||||
query = query.Where(u => u.Department == department);
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
||||
private static string TruncateContent(string content) =>
|
||||
content.Length > 50 ? content[..50] + "..." : content;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user