public void SmsNotification() { //Arrange var atTimes = new List <DateTime> { DateTime.Now, DateTime.Now.AddHours(3) }; var afterHours = new List <int> { 4, 5 }; var source = new SmsNotification(); source.NotifyAfterHours.AddRange(afterHours); source.NotifyAtTimes.AddRange(atTimes); var expectedDto = new smsnotification { afterhours = afterHours.ToArray(), at = atTimes.Select(a => new listedtime { timeSpecified = true, time = a }).ToArray() }; //Act var actual = DataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actual); }
public IHttpActionResult PutSmsNotification(long id, SmsNotification smsNotification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != smsNotification.SmsNotificationId) { return(BadRequest()); } db.Entry(smsNotification).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SmsNotificationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public NotificationFacade(EmailNotification emailNotification, InternalNotification internalNotification, MobileNotification mobileNotification, SmsNotification smsNotification) { EmailNotification = emailNotification; InternalNotification = internalNotification; MobileNotification = mobileNotification; SmsNotification = smsNotification; }
private IOutcome SendNotification(Order createdOrder) { var sms = new SmsNotification() { From = _appSettings.Notification.Sms.From, To = createdOrder.Phone, Message = $"Заказ № {createdOrder.Id} принят. Ожидайте такси к {createdOrder.When}" }; return(_notifier.Send(sms)); }
public IHttpActionResult GetSmsNotification(long id) { SmsNotification smsNotification = db.SmsNotifications.Find(id); if (smsNotification == null) { return(NotFound()); } return(Ok(smsNotification)); }
public Task SendAsync(IdentityMessage message) { var notification = new SmsNotification() { ToPhoneNumber = message.Destination, Content = message.Body }; Send(notification); return(Task.CompletedTask); }
public IHttpActionResult PostSmsNotification(SmsNotification smsNotification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SmsNotifications.Add(smsNotification); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = smsNotification.SmsNotificationId }, smsNotification)); }
public IHttpActionResult DeleteSmsNotification(long id) { SmsNotification smsNotification = db.SmsNotifications.Find(id); if (smsNotification == null) { return(NotFound()); } db.SmsNotifications.Remove(smsNotification); db.SaveChanges(); return(Ok(smsNotification)); }
public static ISmsNotification FromDataTransferObject(smsnotification smsNotificationDto) { if (smsNotificationDto == null) { return(null); } var smsNotification = new SmsNotification { NotifyAfterHours = smsNotificationDto.afterhours?.ToList() ?? new List <int>(), NotifyAtTimes = smsNotificationDto.at?.Select(listedTime => listedTime.time).ToList() ?? new List <DateTime>() }; return(smsNotification); }
public static bool AddSmsNotification(SmsNotification sms) { try { using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities()) { db.SmsNotifications.Add(sms); db.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public void WithSendingTime() { //Arrange var firstSmsNotification = DateTime.Today; var secondSmsNotification = DateTime.Today.AddDays(1); var expected = new List <DateTime> { firstSmsNotification, secondSmsNotification }; ISmsNotification smsNotification = new SmsNotification(expected.ToArray()); //Act var actual = smsNotification.NotifyAtTimes; //Assert Comparator.AssertEqual(expected, actual); }
public void WithAfterHours() { //Arrange var firstSmsNotification = 2; var secondSmsNotification = 5; var expected = new List <int> { firstSmsNotification, secondSmsNotification }; ISmsNotification smsNotification = new SmsNotification(expected.ToArray()); //Act var actual = smsNotification.NotifyAfterHours; //Assert Comparator.AssertEqual(expected, actual); }
public IActionResult generateOTP([FromBody] GenerateOTP otp) { try { string OTPValue = Common.GenerateOTP(); SMSResponse results = new SMSResponse(); var message = ""; //otp.emailorPhone = "+14087224019"; string SaveOtpValue = Data.User.GenerateOTP(OTPValue, otp); if (SaveOtpValue == "Success") { results = SmsNotification.SendMessage(otp.phone, "Hi User, your OTP is " + OTPValue + " and it's expiry time is 15 minutes."); string status = results.messages[0].status.ToString(); if (status == "0") { message = "Message sent successfully."; } else { string err = results.messages[0].error_text.ToString(); message = err; } return(StatusCode((int)HttpStatusCode.OK, new { message })); } else { return(StatusCode((int)HttpStatusCode.InternalServerError, new { ErrorMessage = SaveOtpValue })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("generateOTP", e.Message.ToString()); return(StatusCode((int)HttpStatusCode.InternalServerError, new { ErrorMessage = e.Message.ToString() })); } }
public void Invoice() { //Arrange var contentBytes = new byte[] { 0xb2 }; var smsNotification = new SmsNotification(DateTime.Today.AddHours(3)); var source = new Invoice( "subject", "txt", contentBytes, 100, "8902438456", DateTime.Today, "123123123", AuthenticationLevel.TwoFactor, SensitivityLevel.Sensitive, smsNotification); var expectedDto = new invoice { subject = source.Subject, filetype = source.FileType, authenticationlevel = source.AuthenticationLevel.ToAuthenticationLevel(), authenticationlevelSpecified = true, sensitivitylevel = source.SensitivityLevel.ToSensitivityLevel(), sensitivitylevelSpecified = true, smsnotification = new smsnotification { at = new[] { new listedtime { time = smsNotification.NotifyAtTimes.First(), timeSpecified = true } } }, uuid = source.Guid, kid = source.Kid, amount = source.Amount, account = source.Account, duedate = source.Duedate }; //Act var actualDto = SendDataTransferObjectConverter.ToDataTransferObject(source); //Assert Comparator.AssertEqual(expectedDto, actualDto); }
public void should_create_notification_with_sms_type_and_phone_number() { const NotificationType notificationType = NotificationType.CreateIndividual; const MessageType messageType = MessageType.SMS; const string phoneNumber = "123456789"; var patId = Guid.NewGuid(); var hearingId = Guid.NewGuid(); var notificationId = Guid.NewGuid(); var notification = new SmsNotification(notificationId, notificationType, phoneNumber, patId, hearingId); notification.Id.Should().NotBeEmpty(); notification.PhoneNumber.Should().Be(phoneNumber); notification.ParticipantRefId.Should().Be(patId); notification.HearingRefId.Should().Be(hearingId); notification.DeliveryStatus.Should().Be(DeliveryStatus.NotSent); notification.MessageType.Should().Be(messageType); notification.NotificationType.Should().Be(notificationType); }
///<summary>A list item per each clinic indicating the number of messages which have not yet been read for that clinic (practice). ///Inserts a new InvalidType.SmsTextMsgReceivedUnreadCount signal.</summary> public static List <SmsNotification> UpdateSmsNotification() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <SmsNotification> >(MethodBase.GetCurrentMethod())); } string command = "SELECT ClinicNum,COUNT(*) AS CountUnread FROM smsfrommobile WHERE SmsStatus=0 GROUP BY ClinicNum"; List <SmsNotification> ret = Db.GetTable(command).AsEnumerable() .Select(x => new SmsNotification() { ClinicNum = PIn.Long(x["ClinicNum"].ToString()), Count = PIn.Int(x["CountUnread"].ToString()), }).ToList(); //Insert as structured data signal so all workstations won't have to query the db to get the counts. They will get it directly from Signalod.MsgValue. Signalods.InsertSmsNotification(SmsNotification.GetJsonFromList(ret)); return(ret); }
public ActionResult SendSmsNotification() { try { var profileModel = new ProfileViewModel(); var userId = User.Identity.GetUserId(); var SmsRepository = new SmsNotification(); var userRepository = new UserRepository(); var user = userRepository.GetUser(userId); string number = user.Phone; string message = " Namn: " + user.Firstname.ToString() + user.Lastname.ToString() + " " + " Mail " + user.Email.ToString() + " " + " Telefonnr: " + user.Phone.ToString() + " " + " Titel: " + user.Title.ToString(); SmsRepository.SendSmsNotification(number, message); return(RedirectToAction("Index", "Home")); } catch (Exception e) { return(View()); } }
public virtual async Task<IMessageDeliveryResult> Send(byte[] fileContent, string filetype, string subject,IdentificationType identification, string identificationValue, SensitivityLevel sensitivity = SensitivityLevel.Normal, AuthenticationLevel authentication = AuthenticationLevel.Password, SmsNotification smsNotification = null,PrintDetails printDetails= null) { var recipient = new RecipientById(identification, identificationValue); var primaryDocument = new Document(subject, filetype, fileContent) { SensitivityLevel = sensitivity, AuthenticationLevel = authentication }; if (smsNotification != null) primaryDocument.SmsNotification = smsNotification; var m = new Message(recipient, primaryDocument); if (printDetails != null) m.PrintDetails = printDetails; return await GetClient().SendMessageAsync(m); }
public void Delete(int Id) { SmsNotification smsNotification = context.SmsNotifications.Find(Id); context.SmsNotifications.Remove(smsNotification); }
public IActionResult SmsOTP(string PhoneNumber) { try { string OTPValue = Common.GenerateOTP(); SMSResponse results = new SMSResponse(); //results = SmsNotification.SendMessage(PhoneNumber, "Hi User, your OTP is" + OTPValue + "and it's expiry time is 5 minutes.").ToString(); //// results = SmsNotification.SendMessage(userlogin.PhoneNumber, "Hi User, your OTP is" + OTPValue + "and it's expiry time is 5 minutes.").Status.ToString(); var SmsStatus = ""; //if (results == "RanToCompletion") //{ // string SaveOtpValue = Data.Common.SaveOTP("4560123045", OTPValue, "Phone"); // SmsStatus = "Message sent successfully."; //} //else //{ // SmsStatus = "Message not sent.."; //} PhoneNumber = "+14087224019"; string SaveOtpValue = Data.Common.SaveOTP(PhoneNumber, OTPValue, "Phone"); if (SaveOtpValue == "Success") { //SMSResponse results = SmsNotification.SendMessage(PhoneNumber, "Hi User, your OTP is " + OTPValue + " and it's expiry time is 5 minutes."); results = SmsNotification.SendMessage(PhoneNumber, "Hi User, your OTP is " + OTPValue + " and it's expiry time is 5 minutes."); string status = results.messages[0].status.ToString(); if (status == "0") { SmsStatus = "Message sent successfully."; } else { string err = results.messages[0].error_text.ToString(); SmsStatus = err; } // results = SmsNotification.SendMessage(PhoneNumber, "Hi User, your OTP is " + OTPValue + " and it's expiry time is 5 minutes."); //var res = new List<SMSResponseDetail>(); //res = results.messages; return(StatusCode((int)HttpStatusCode.OK, new { SmsStatus })); //results.messages, } else { return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "Phone number not available" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("SmsOTP", e.Message.ToString()); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }
public SubmitMessageController(SubmitMessageDomain SubmitMessageDomain, SmsNotification SmsNotificationService, ResponceSubmitReqDomain ResponceSubmitReqDomain) { _SubmitMessageDomain = SubmitMessageDomain; _ SmsNotificationService = SmsNotificationService; _ ResponceSubmitReqDomain = ResponceSubmitReqDomain; }
public void Send(SmsNotification notification) { Logger.Information("Sent SMS {SMS}", notification); }
protected void gvVehicle_SelectedIndexChanged(object sender, EventArgs e) { try { User usr = null; if (Session["user"] != null) { usr = (User)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } String DriverName = ((Label)gvVehicle.SelectedRow.FindControl("lbDrv")).Text; String DriverMobile = ((Label)gvVehicle.SelectedRow.FindControl("lbDrvFone")).Text; String VehicleMake = ((Label)gvVehicle.SelectedRow.FindControl("lbMaker")).Text; int VehicleID = Convert.ToInt32(gvVehicle.SelectedDataKey["ID"].ToString()); int requestId = Convert.ToInt32(hid.Value); SmsNotification sms = new SmsNotification(); Trip trip = TripBLL.GetTripDetailByID(requestId); Vehicle veh = VehicleBLL.GetVehicle(VehicleID); if (trip != null) { trip.Status = (int)Utility.FleetRequestStatus.Enroute; trip.DateAssigned = DateTime.Now; trip.AssignedBy = usr.ID; trip.AssignedVehicle = VehicleID; trip.MileageAtDeparture = veh.Mileage.HasValue ? veh.Mileage.Value : 0; Department dept = DepartmentBLL.GetDepartment(trip.DepartmentID.Value); sms.PHONE = DriverMobile; sms.SENDER = smsSender; sms.MESSAGE = "easyFLEET:Trip Assigned:: #Location:" + trip.Location.ToUpper() + " #Destination:" + trip.Destination.ToUpper() + " #Date:" + trip.TripDate.Value.ToString("dd-MMM-yyyy").ToUpper() + " #DepartureTime:" + trip.ExpectedDepartureTime + " #Requestor:" + trip.InitiatorName.ToUpper() + " #Dept:" + dept.Name + " Thanks."; sms.STATUS = "U"; if (TripBLL.UpdateTrip(trip)) { BindGrid(requestId); if (veh != null) { veh.Status = (int)Utility.VehicleStatus.Enroute; VehicleBLL.UpdateVehicle(veh); } //Send Sms to drive---to do Utility.AddSmsNotification(sms); lnkCheckAvailabity.Enabled = false; lnkHold.Visible = false; //send Email to Requestor and sms to Driver string body = ""; string from = ConfigurationManager.AppSettings["exUser"].ToString(); string appLogo = ConfigurationManager.AppSettings["appLogoUrl"].ToString(); string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string subject = "Vehicle Assignment Notification"; string FilePath = Server.MapPath("EmailTemplates/"); if (File.Exists(FilePath + "VehicleAssignedNotification.htm")) { FileStream f1 = new FileStream(FilePath + "VehicleAssignedNotification.htm", FileMode.Open); StreamReader sr = new StreamReader(f1); body = sr.ReadToEnd(); body = body.Replace("@add_appLogo", appLogo); body = body.Replace("@add_siteUrl", siteUrl); //body = body.Replace("@add_Initiator", trip.InitiatorName); body = body.Replace("@dd_RequestID", trip.ID.ToString()); body = body.Replace("@add_Plate", veh.PlateNo); body = body.Replace("@add_driver", DriverName); body = body.Replace("@add_Mobile", DriverMobile); body = body.Replace("add_vehicleName", veh.Name + "[" + veh.PlateNo + "]"); // body = body.Replace("@add_approver", usr.StaffName); //Replace the values from DB or any other source to personalize each mail. f1.Close(); } try { string rst2 = Utility.SendMail(trip.InitiatorEmail, from, "", subject, body); } catch { } success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> Request has been successfully Treated. Notifications has been sent to Initiator, SMS has been sent to the Assigned Driver"; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.InnerException); return; } }
public static async Task <IDisposableEntity <SmsNotification> > CreateSmsNotificationAsync( this TestServiceScope scope, string message = TestingConstants.Placeholder, EventInfo eventInfo = null, Product product = null, Organization organization = null, ApplicationUser createdByUser = null, NotificationStatus?status = null, int?totalSent = null, int?totalErrors = null, IEnumerable <string> phones = null, IEnumerable <ApplicationUser> recipientUsers = null, IEnumerable <Registration> registrations = null) { if (TestingConstants.Placeholder.Equals(message)) { message = $"Test SMS message {Guid.NewGuid()}"; } var recipients = new List <NotificationRecipient>(); if (phones != null) { recipients.AddRange(phones .Select(NotificationRecipient.Sms)); } if (recipientUsers != null) { recipients.AddRange(recipientUsers .Select(NotificationRecipient.Sms)); } if (registrations != null) { recipients.AddRange(registrations .Select(NotificationRecipient.Sms)); } var disposables = new List <IDisposable>(); if (createdByUser == null) { var disposableUser = await scope.CreateUserAsync(); createdByUser = disposableUser.Entity; disposables.Add(disposableUser); } NotificationStatistics stats = null; if (totalSent.HasValue || totalErrors.HasValue) { stats = new NotificationStatistics { SentTotal = totalSent ?? 0, ErrorsTotal = totalErrors ?? 0 }; } eventInfo ??= product?.EventInfo; organization ??= eventInfo?.Organization; var notification = new SmsNotification(message) { EventInfo = eventInfo, Product = product, Organization = organization, CreatedByUser = createdByUser, Status = status ?? NotificationStatus.New, Recipients = recipients, Statistics = stats }; await scope.Db.Notifications.AddAsync(notification); await scope.Db.SaveChangesAsync(); return(new DisposableEntity <SmsNotification>(notification, scope.Db, disposables.ToArray())); }
public NotificationController() { _emailNotification = new EmailNotification(); _smsNotification = new SmsNotification(); _pushNotification = new PushNotification(); }
public void apply(SmsNotification notification) { System.Console.WriteLine($"SMS notification is sent to the user phone number {notification.PhoneNumber}"); }
public void Create(SmsNotification smsNotification) { context.SmsNotifications.Add(smsNotification); }
public void apply(SmsNotification notification) { System.Console.WriteLine($"User phone number {notification.PhoneNumber} subscribed to SMS notification"); }
public void Update(SmsNotification smsNotification) { context.Entry(smsNotification).State = EntityState.Modified; }