当前位置: 首页>>代码示例>>C#>>正文


C# TList.FirstOrDefault方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:williams55,项目名称:clinic-doctor,代码行数:101,代码来源:SmsBO.cs


注:本文中的TList.FirstOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。