/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { if (SamAccountName != null) { Response.error = Label.Get("error.firebase.alreadySubscribed", DTO.LngIsoCode); return(false); } else { if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken)) { Response.error = Label.Get("error.authentication", DTO.LngIsoCode); return(false); } } Subscriber_ADO ado = new Subscriber_ADO(Ado); Subscriber_BSO sBso = new Subscriber_BSO(); string newKey = sBso.GetSubscriberKey(DTO.Uid); if (ado.UpdateKey(DTO.Uid, newKey)) { Response.data = JSONRPC.success; return(true); } Log.Instance.Debug("Can't update Subscriber Key"); Response.error = Label.Get("error.update", DTO.LngIsoCode); return(false); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { if (SamAccountName != null) { Response.error = Label.Get("error.firebase.alreadySubscribed", DTO.LngIsoCode); return(false); } if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken)) { Response.error = Label.Get("error.authentication"); return(false); } Subscriber_BSO bso = new Subscriber_BSO(); if (bso.Create(Ado, DTO.SbrPreference, DTO.Uid, DTO.LngIsoCode)) { //Calling GetSubscribers with readCache=false will cause the cache to be refreshed to include the new user bso.GetSubscribers(Ado, null, false); Response.data = JSONRPC.success; return(true); } Log.Instance.Debug("Can't create Subscription"); Response.error = Label.Get("error.create"); return(false); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { if (SamAccountName != null) { Response.error = Label.Get("error.authentication"); return(false); } if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken)) { Response.error = Label.Get("error.authentication"); return(false); } Subscriber_BSO sbso = new Subscriber_BSO(); var responseSubscriber = sbso.GetSubscribers(Ado, DTO.Uid); if (responseSubscriber.Count > 0) { Response.data = responseSubscriber.FirstOrDefault(); return(true); } return(false); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { Subscriber_BSO sbso = new Subscriber_BSO(); var response = sbso.GetSubscribers(Ado, DTO.Uid); if (response.Count > 0) { Response.data = response; return(true); } return(false); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { string subscriberUserId; //A local/ad user can't delete themselves //However an admin user can delete a subscriber if (SamAccountName != null) { if (IsAdministrator() && DTO.Uid != null) { subscriberUserId = DTO.Uid; } else { Response.error = Label.Get("error.authentication"); return(false); } } else { //The subscriber is attempting to delete themselves if (!API.Firebase.Authenticate(DTO.Uid, DTO.AccessToken)) { Response.error = Label.Get("error.authentication"); return(false); } subscriberUserId = DTO.Uid; } Subscriber_BSO bso = new Subscriber_BSO(); if (bso.Delete(Ado, subscriberUserId)) { //Delete the user also from Firebase API.Firebase.DeleteUser(subscriberUserId); //Refresh the cache of subscriber keys (for throttling) new Subscriber_BSO().RefreshSubscriberKeyCache(Ado); //Refresh the cache of subscribers (for reading) bso.GetSubscribers(Ado, null, false); Response.data = JSONRPC.success; return(true); } Log.Instance.Debug("Can't delete Subscriber"); Response.error = Label.Get("error.delete"); return(false); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { if (Common.FirebaseId == null && SamAccountName == null) { Response.error = Label.Get("error.authentication"); return(false); } using (eMail email = new eMail()) { string Body = ""; string Subject = ""; Body = Label.Get("email.body.subscription-notification", DTO.LngIsoCode); Subject = Label.Get("email.subject.subscription-notification", DTO.LngIsoCode); email.Body = Body; email.Subject = Subject; // Get user from FirebaseId Subscriber_BSO sbso = new Subscriber_BSO(); var user = sbso.GetSubscribers(Ado, Common.FirebaseId); if (user.FirstOrDefault() == null) { Log.Instance.Debug("Cannot send notification because email address is null"); Response.error = Label.Get("error.notification"); return(false); } // Get email address from user string emailAddress = user.FirstOrDefault().CcnEmail; email.To.Add(emailAddress); Log.Instance.Debug($"Send notification to {emailAddress}"); email.Send(); } return(true); }