public static Sms FindOrCreate(SmsDTO smsDTO, ISendSMSHostContext db) { Sms sms = FindSmsById(Guid.Parse(smsDTO.Id), db); if (sms == null) { sms = new Sms() { Id = Guid.Parse(smsDTO.Id), Message = smsDTO.Message, TimeStamp = DateTime.Parse(smsDTO.TimeStamp), Status = Status.FindStatusById(smsDTO.StatusId, db), Contact = Contact.FindOrCreate( new ContactDTO { Id = smsDTO.ContactId, FirstName = smsDTO.ContactFirstName, LastName = smsDTO.ContactLastName, Number = smsDTO.ContactNumber, IsAnonymous = smsDTO.ContactFirstName == "" && smsDTO.ContactLastName == "" }, db) }; } return(sms); }
public Sms(SmsDTO smsDTO, ISendSMSHostContext db) { Id = Guid.Parse(smsDTO.Id ?? Guid.NewGuid().ToString()); Message = smsDTO.Message; TimeStamp = DateTime.Parse(smsDTO.TimeStamp ?? DateTime.Now.ToString()); Status = Status.FindStatusById(smsDTO.StatusId, db); Contact = Contact.FindOrCreate( new ContactDTO { Id = smsDTO.ContactId, FirstName = smsDTO.ContactFirstName, LastName = smsDTO.ContactLastName, Number = smsDTO.ContactNumber, IsAnonymous = smsDTO.ContactFirstName == "" && smsDTO.ContactLastName == "" }, db); }
public Sms CopyFromSmsDTO(SmsDTO smsDTO, ISendSMSHostContext db) { Message = smsDTO.Message; TimeStamp = DateTime.Parse(smsDTO.TimeStamp); Status = Status.FindStatusById(smsDTO.StatusId, db); Contact contact = Contact.FindOrCreate( new ContactDTO { Id = smsDTO.ContactId, FirstName = smsDTO.ContactFirstName, LastName = smsDTO.ContactLastName, Number = smsDTO.ContactNumber, IsAnonymous = smsDTO.ContactFirstName == "" && smsDTO.ContactLastName == "" }, db); Contact = contact; return(this); }