public async Task <SMSDto> UpdateSMS(SMSDto sms) { using (CellularCompanyContext db = new CellularCompanyContext()) { try { if (sms != null) { SMSEntity entity = sms.ToModel(); entity.SMSId = sms.SMSId; db.SMS.Attach(entity); foreach (var propName in db.Entry(entity).CurrentValues.PropertyNames) { if (propName != "SMSId") { db.Entry(entity).Property(propName).IsModified = true; } } await db.SaveChangesAsync(); return(entity.ToDto()); } return(null); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } } }
public async Task <SMSDto> UpdateSMS(int id, SMSDto smsDto) { using (CellularCompanyContext db = new CellularCompanyContext()) { if (id != smsDto.SMSId) { return(null); } else { var sms = db.SMSs.FirstOrDefault(s => s.SMSId == id); if (sms == null) { return(null); } else { SMS sMS = smsDto.ToModel(); db.Entry(sMS).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); return(sms.ToDto()); } } } }
public bool SendSMS(SMSDto dto) { try { _commonTokens = _commonTokens ?? new List <Token>(); #region token replacement //replcaing sms text with default tokens dto.SMSText = _tokenHelperService.Replace(dto.SMSText, _commonTokens, true); //replacing sms text with sms specific tokens dto.SMSText = _tokenHelperService.Replace(dto.SMSText, dto.SMSSpecificTokens, true); #endregion string accountSid = _accountSID; string authToken = _authenticationToken; TwilioClient.Init(accountSid, authToken); var to = new PhoneNumber(dto.SMSToPhoneNumber); var message = MessageResource.Create( to, from: new PhoneNumber(_smsFromPhoneNumber), // From number, must be an SMS-enabled Twilio number ( This will send sms from ur "To" numbers ). body: dto.SMSText); return(true); } catch (Exception ex) { _loggerService.Error(ex, ex.Message, null); return(true); } }
public async Task <SMSDto> CreateSMS(SMSDto sms) { Task <SMSDto> smsDto; lock (obj) { smsDto = smsManager.AddSMSDto(sms); } return(await smsDto); }
public async Task <SMSDto> CreateSMS(SMSDto sms) { Task <SMSDto> smsDto; lock (_obj) { smsDto = _smsProvider.AddSMS(sms); } return(await smsDto); }
public static SMSEntity ToModel(this SMSDto sms) { return(new SMSEntity() { DestinationNumber = sms.DestinationNumber, ExternalPrice = sms.ExternalPrice, LineId = sms.LineId, SMSId = sms.SMSId, //Line=sms.Line.ToModel() }); }
public static SMS ToModel(this SMSDto smsDto) { if (smsDto == null) { return(null); } return(new SMS { LineId = smsDto.LineId, SMSId = smsDto.SMSId, DestinationNumber = smsDto.DestinationNumber, ExternalPrice = smsDto.ExternalPrice, Line = smsDto.Line.ToModel() }); }
public static SMSEntity ToModel(this SMSDto sms) { if (sms == null) { return(null); } return(new SMSEntity() { DestinationNumber = sms.DestinationNumber, ExternalPrice = sms.ExternalPrice, LineId = sms.LineId, SMSId = sms.SMSId, Line = sms.Line.ToModel(), Time = sms.Time }); }
public async Task <SMSDto> CreateSMS(SMSDto smsDto) { using (CellularCompanyContext db = new CellularCompanyContext()) { if (smsDto == null) { return(null); } else { db.SMSs.Add(smsDto.ToModel()); await db.SaveChangesAsync(); return(smsDto); } } }
public async Task CreateCommunication(CommunicationModel communication, bool isSms, double duration) { communication.Time = DateTime.Now; communication.LineId = communication.Line.LineId; if (isSms) { SMSDto sms = ModelExtensions.ToSms(communication); if (sms != null) { await invoice.AddSMSAsync(sms); } } else { CallsDto call = ModelExtensions.ToCall(communication, duration); if (call != null) { await invoice.AddCallAsync(call); } } }
public async Task <SMSDto> CreateSMS(SMSDto sms) { using (CellularCompanyContext db = new CellularCompanyContext()) { try { if (sms != null) { SMSEntity entity = sms.ToModel(); db.SMS.Add(entity); await db.SaveChangesAsync(); return(sms); } return(null); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } } }
public async Task <SMSDto> UpdateSMSDto(SMSDto dto) { return(await GetContainer().Resolve <ISMSRepository>().UpdateSMS(dto)); }
public async Task <SMSDto> UpdateSMS(int id, SMSDto smsDto) { return(await GetContainer().Resolve <ISMSRepository>().UpdateSMS(id, smsDto)); }
public async Task <SMSDto> AddSMS(SMSDto smsDto) { return(await GetContainer().Resolve <ISMSRepository>().CreateSMS(smsDto)); }
public async Task <SMSDto> AddSMS(SMSDto sms) { return(await _manager.CreateSMS(sms)); }
public async Task <SMSDto> AddSMS(SMSDto sms) { return(await _invoiceProvider.CreateSMS(sms)); }