本文整理汇总了C#中TList.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# TList.FirstOrDefault方法的具体用法?C# TList.FirstOrDefault怎么用?C# TList.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList.FirstOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendSmsAppointment
public bool SendSmsAppointment(string apptId, SmsCase smsCase, out string messageCode)
{
bool result = false;
messageCode = MessageCode.GeneralCode.SystemError;
try
{
SingletonLogger.Instance.Debug(String.Format("SendSmsAppointment-------ApptId: {0}", apptId));
#region Validate
var appt = DataRepository.AppointmentProvider.GetById(apptId);
if (appt == null || appt.IsDisabled)
{
messageCode = MessageCode.SmsCode.ApptNotExists;
return false;
}
var patient = DataRepository.VcsPatientProvider.GetByPatientCode(appt.PatientCode).FirstOrDefault();
if (patient == null || string.IsNullOrEmpty(patient.MobilePhone))
{
messageCode = MessageCode.SmsCode.NoMobile;
return false;
}
#endregion
#region Lấy thông tin
// Lấy đầy đủ thông tin
var doctor = DataRepository.UsersProvider.GetByUsername(appt.Username);
var room = DataRepository.RoomProvider.GetById(appt.RoomId.HasValue ? appt.RoomId.Value : 0);
var service =
DataRepository.ServicesProvider.GetById(appt.ServicesId.HasValue ? appt.ServicesId.Value : 0);
string doctorName = doctor == null ? string.Empty : doctor.Firstname,
roomName = room == null ? string.Empty : room.Title,
serviceName = service == null ? string.Empty : service.Title;
#endregion
#region Lưu Sms, Receiver, Log
var sms = DataRepository.SmsProvider.GetByAppointmentId(apptId).FirstOrDefault();
var receivers = new TList<SmsReceiver>();
if (sms == null)
{
sms = new Sms
{
EntityState = EntityState.Added
};
}
else
{
sms.EntityState = EntityState.Changed;
receivers = DataRepository.SmsReceiverProvider.GetBySmsId(sms.Id);
}
switch (smsCase)
{
case SmsCase.WebApp:
sms.Message = String.Format(ServiceFacade.SettingsHelper.ApptSmsTemplate, patient.FirstName,
appt.StartTime, doctorName, roomName, serviceName);
break;
case SmsCase.Auto:
sms.Message = String.Format(ServiceFacade.SettingsHelper.ApptAutoSmsTemplate, patient.FirstName,
appt.StartTime, doctorName, roomName, serviceName);
break;
}
sms.SmsType = SmsType.Appointment;
sms.SendTime = DateTime.Now;
sms.IsSendNow = true;
sms.IsSent = false;
sms.SendingTimes += 1;
sms.AppointmentId = appt.Id;
sms = DataRepository.SmsProvider.Save(sms);
if (sms == null)
{
return false;
}
var receiver = receivers.FirstOrDefault(x => x.Mobile.Equals(patient.MobilePhone));
if (receiver == null)
{
receiver = new SmsReceiver
{
Mobile = patient.MobilePhone,
FirstName = patient.FirstName,
LastName = patient.LastName,
UserType = SmsUserType.Patient,
SmsId = sms.Id,
IsSent = false,
SendingTimes = 0,
CreateDate = DateTime.Now
};
DataRepository.SmsReceiverProvider.Insert(receiver);
}
var smsLog = new SmsLog
{
Id = Guid.NewGuid(),
SmsId = sms.Id,
Message = sms.Message,
Mobile = receiver.Mobile,
SendTime = sms.SendTime,
RealSendTime = DateTime.Now,
IsSent = false
//.........这里部分代码省略.........