public void UserAlertViewed(string userId, int alertId) { UserAlert userAlert = repo.GetUserAlertByUserAndAlert(userId, alertId); userAlert.Show = false; repo.UpdateUserAlert(userAlert); }
}// end OnCreate void DeleteAlarm(UserAlert userAlert) { // start a new thread - so as not to run on the UI thread - keep the UI thread responsive Task.Factory.StartNew(() => { try { int alarmNo_takenFrom_UserAlertID = userAlert.UserAlertID; Intent intent = new Intent(this, typeof(Receiver1)); // CONTEXT,PRIVATE REQUEST CODE, INTENT, FLAG PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, alarmNo_takenFrom_UserAlertID, intent, 0); AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService); alarmManager.Cancel(pendingIntent); //alarmManager.Set(AlarmType.RtcWakeup, ringTime, pendingIntent); Log.Debug("DEBUG", "\n\n\nAlarm deleted from Alarm Manager - ID: " + alarmNo_takenFrom_UserAlertID); } catch { Log.Debug("DEBUG", "Alarm NOT deleted from Alarm Manager\n\n\n"); } Log.Debug("DEBUG", "FINISHED\n\n\n"); }); // end of thread }
public async Task <UserAlert> UpdateAsync(string userId, UserAlert data) { var repoUser = await this._userRepository.GetAsync(userId); var repoUserAlert = repoUser.Alerts.SingleOrDefault(x => x.Id == data.Id); if (repoUserAlert == null) { throw new KeyNotFoundException(); } repoUserAlert.Title = data.Title; repoUserAlert.BestCurrentDeal = data.BestCurrentDeal; repoUserAlert.Entries = data.Entries; repoUserAlert.IsActive = data.IsActive; repoUserAlert.IsDeleted = data.IsDeleted; repoUserAlert.LastModifiedAt = DateTime.UtcNow; Task.WaitAll( this._userRepository.UpdateAsync(userId, repoUser), this.UpdateListsWithAlert(userId, repoUserAlert)); var updatedAlert = await this.GetAsync(userId, data.Id); return(updatedAlert); }
public async Task <ActionResult> DeleteRequest(int?id) { try { if (id != null) { UserAlert ua = new UserAlert(); var data = db.SubmitLeaves.Single(x => x.ID == id); db.SubmitLeaves.Remove(data); db.SaveChanges(); data.IsActive = true; ua.ApplicationUserID = data.ApplicationUserID; var name = data.ApplicationUser.Name; string Description = "Dear " + name + " your leave from " + data.GetFormDate.ToString() + " to date " + data.GetToDate.ToString() + " is rejected.Please contact to admin"; ua.Description = Description; ua.IsActive = true; db.UserAlerts.Add(ua); db.SaveChanges(); var message = new IdentityMessage { Body = Description, Destination = data.ApplicationUser.Email, Subject = "Leave rejected" }; //await EmailService.SendEmailAsync(message); return(RedirectToAction("LeaveRequest")); } return(View()); } catch (Exception) { throw; } }
public async void OnRegister(object argParam) { try { if (!this.User.Password.Equals(this.User.ConfirmPassword)) { throw new Exception("The password should be same!"); } var lcManager = App.CenteralIOC.Resolve <IUserManager>(); var lcUser = await lcManager.fnRegisterSystem(new User { IsActive = true, CreatedDate = DateTime.Now, NameSurname = this.User.NameSurname, SecretQuestion = this.User.SecretQuestion, Username = this.User.Username }, this.User.Password, this.User.SecretAnswer); if (lcUser != null) { App.CurrentUser = lcUser; NavigationManger.fnNavigateHome(); } } catch (System.Exception ex) { UserAlert.fnInformUser(UserInformType.Error, "Error", ex.Message); } }
public async Task <JsonResult> ToggleNSFW(int id) { var userId = User.Identity.GetUserId(); if (userId == null) { Response.StatusCode = (int)HttpStatusCode.Forbidden; return(Json(new { success = false, message = "Credentials failure" }, JsonRequestBehavior.AllowGet)); } using (var db = new ZapContext()) { var post = await db.Posts .Include(p => p.UserId) .FirstOrDefaultAsync(p => p.PostId == id).ConfigureAwait(false); if (post == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(new { success = false, message = "Invalid post" }, JsonRequestBehavior.AllowGet)); } var callingUserIsMod = await db.Users .Where(u => u.AppId == userId) .SelectMany(u => u.GroupModeration.Select(g => g.GroupId)) .ContainsAsync(post.Group.GroupId).ConfigureAwait(false); if (post.UserId.AppId == userId || UserManager.IsInRole(userId, "Administrator") || callingUserIsMod) { post.IsNSFW = !post.IsNSFW; // Alert the post owner var postOwner = post.UserId; // Add Alert var alert = new UserAlert() { TimeStamp = DateTime.Now, Title = (post.IsNSFW ? "Your post has been marked NSFW : " : "Your post is no longer marked NSFW : ") + post.PostTitle, Content = "A moderator has changed the Not Safe For Work status of your post.", IsDeleted = false, IsRead = false, To = postOwner, PostLink = post, }; postOwner.Alerts.Add(alert); await db.SaveChangesAsync().ConfigureAwait(false); return(Json(new { success = true, message = "Success", post.IsNSFW }, JsonRequestBehavior.AllowGet)); } else { Response.StatusCode = (int)HttpStatusCode.Forbidden; return(Json(new { message = "Credentials failure" }, JsonRequestBehavior.AllowGet)); } } }
//Employee Alerts public ActionResult EmployeeAlerts(UserAlert userAlert) { var id = User.Identity.GetUserId(); var query = from u in db.UserAlerts where u.IsActive == true && u.ApplicationUserID.Equals(id) select u; return(View(query.ToList())); }
public void UpdateUserAlert(int id, bool web, bool mail, bool app) { UserAlert userAlert = repo.GetUserAlert(id); userAlert.Web = web; userAlert.Mail = mail; userAlert.App = app; repo.UpdateUserAlert(userAlert); }
/// <summary> /// /// </summary> /// <param name="postId"></param> /// <returns></returns> public bool AlertNewPost(long postId) { using (var db = new ZapContext()) { var followUsers = db.Posts .Where(p => p.PostId == postId) .SelectMany(p => p.UserId.Followers) .Select(u => new { u.Id, u.AppId, u.Settings.NotifyOnNewPostSubscribedUser, u.Settings.AlertOnNewPostSubscribedUser, user = u, }).ToList(); if (followUsers.Any()) { var postInfo = db.Posts .Where(p => p.PostId == postId) .Select(p => new { Post = p, p.UserId.Name }) .FirstOrDefault(); foreach (var follower in followUsers) { // Add Alert if (follower.AlertOnNewPostSubscribedUser) { var alert = new UserAlert() { TimeStamp = DateTime.Now, Title = "New post by a user you are following: <a href='/User/" + Uri.EscapeDataString(postInfo.Name) + "'>" + postInfo.Name + "</a>", Content = "", IsDeleted = false, IsRead = false, To = follower.user, PostLink = postInfo.Post, }; follower.user.Alerts.Add(alert); if (follower.user.Settings == null) { follower.user.Settings = new UserSettings(); } } } db.SaveChanges(); } return(true); } }
public void AddUserAlert(string id, string alertType, string subject, bool web, bool mail, bool app, string subjectB, string compare, string subjectProperty, int value) { initNonExistingRepo(true); AccountManager accountManager = new AccountManager(unitOfWorkManager); Alert alert = AddAlert(subject, alertType, subjectB, compare, subjectProperty, value); Account account = accountManager.GetAccountById(id); UserAlert userAlert = new UserAlert(account, alert, web, mail, app); repo.AddUserAlert(userAlert); unitOfWorkManager.Save(); }
// populate UserAlert object with data from screen controls & set Property with this UserAlert object private void BtnSetPersonalAlert_Click(object sender, EventArgs e) { // Perform Validation if (editTxtTitle.Text == string.Empty) { editTxtTitle.RequestFocus(); editTxtTitle.Hint = GetString(Resource.String.personalAlertsActivity_validation_message_enterTitle); } else if (editTxtDescription.Text == string.Empty || editTxtDescription.Text.Length >200) { editTxtDescription.RequestFocus(); editTxtDescription.Text = ""; editTxtDescription.Hint = GetString(Resource.String.personalAlertsActivity_validation_message_enterDescription); } else if (dateIsSet == false) { txtDate.Text = GetString(Resource.String.personalAlertsActivity_validation_message_setDate); btnSetDate.RequestFocus(); } else if (timeIsSet == false) { txtTime.Text = GetString(Resource.String.personalAlertsActivity_validation_message_setTime); btnSetTime.RequestFocus(); } else { // validation is successful UserAlert userAlert = new UserAlert { // don't add ID here - SQLite will do this automatically (auto-increment) Title = editTxtTitle.Text, DescriptionOfPersonalEvent = editTxtDescription.Text, CountryChar = GetString(Resource.String.personalAlertsActivity_personalAlertName), MarketImpact = GetString(Resource.String.personalAlertsActivity_personalAlertName_impact), IsPersonalAlert = true, // convert DateTime object to a ticks (long) DateInTicks = combinedDateTimeObject.Ticks }; Log.Debug("DEBUG", "\n\n\n" + userAlert.ToString() + "\n\n\n"); // reset appropriate validation dateIsSet = false; timeIsSet = false; // call Property in UserAlertActivity to pass data across (newsObject) UserAlertsActivity.SelectedUserAlert_PassedFrom_PersonalAlertsActivity = userAlert; // call intent to start next activity Intent intent = new Intent(this, typeof(UserAlertsActivity)); StartActivity(intent); } }
public static async Task WorkingWithCombinedAlerts() { DbContextOptionsBuilder <ManufacturingContext> optionsBuilder = new DbContextOptionsBuilder <ManufacturingContext>(); optionsBuilder.UseSqlServer("server=172.27.192.1;database=manufacturing_inventory;user=aelmendorf;password=Drizzle123!;MultipleActiveResultSets=true"); using var context = new ManufacturingContext(optionsBuilder.Options); var user = context.Users .Include(e => e.Sessions) .ThenInclude(e => e.Transactions) .Include(e => e.Permission) .FirstOrDefault(e => e.FirstName == "Andrew"); UserService userService = new UserService(); if (user != null) { Session session = new Session(user); await context.Sessions.AddAsync(session); await context.SaveChangesAsync(); userService.CurrentUserName = user.UserName; userService.CurrentSessionId = session.Id; userService.UserPermissionName = user.Permission.Name; } var stockType = await context.Categories.OfType <StockType>().Include(e => e.PartInstances).ThenInclude(e => e.BubblerParameter).FirstOrDefaultAsync(e => e.Id == 16); if (stockType != null) { CombinedAlert tmaAlert = new CombinedAlert(); UserAlert userAlert = new UserAlert(); userAlert.IsEnabled = true; tmaAlert.StockHolder = stockType; userAlert.Alert = tmaAlert; userAlert.User = user; var added = await context.AddAsync(userAlert); if (added != null) { await context.SaveChangesAsync(); Console.WriteLine("Should be saved"); } else { Console.WriteLine("Could Not Save UserAlert"); } } else { Console.WriteLine("StockType is null"); } }
public static async Task WorkingWithIndividualAlerts() { DbContextOptionsBuilder <ManufacturingContext> optionsBuilder = new DbContextOptionsBuilder <ManufacturingContext>(); optionsBuilder.UseSqlServer("server=172.27.192.1;database=manufacturing_inventory;user=aelmendorf;password=Drizzle123!;MultipleActiveResultSets=true"); using var context = new ManufacturingContext(optionsBuilder.Options); var user = context.Users .Include(e => e.Sessions) .ThenInclude(e => e.Transactions) .Include(e => e.Permission) .FirstOrDefault(e => e.FirstName == "Andrew"); UserService userService = new UserService(); if (user != null) { Session session = new Session(user); await context.Sessions.AddAsync(session); await context.SaveChangesAsync(); userService.CurrentUserName = user.UserName; userService.CurrentSessionId = session.Id; userService.UserPermissionName = user.Permission.Name; } var partInstance = await context.PartInstances.Include(e => e.BubblerParameter).Include(e => e.IndividualAlert).FirstOrDefaultAsync(e => e.Id == 1); if (partInstance != null) { IndividualAlert alert = new IndividualAlert(); alert.PartInstance = partInstance; UserAlert userAlert = new UserAlert(); userAlert.Alert = alert; userAlert.User = user; var added = await context.AddAsync(userAlert); if (added != null) { await context.SaveChangesAsync(); Console.WriteLine("Should be saved"); } else { Console.WriteLine("Failed to add Alert"); } } else { Console.WriteLine("PartInstance Not Found"); } }
private static string GetProductTitle(User user, UserAlert alert) { var subject = alert.Title ?? (user.Settings.CorrespondenceLanguage == "en" ? "a product" : "un produit"); if (subject.Length > 30) { subject = subject.Trim().Substring(0, 30) + "..."; } return(subject); }
private async Task UpdateListsWithDeletedAlert(string userId, UserAlert repoUserAlert) { var alertLists = await this._listRepository.GetUserAlertListsAsync(userId); var listsWithCurrentAlert = alertLists.Where(x => x.Alerts.Contains(repoUserAlert)).ToList(); foreach (var list in listsWithCurrentAlert) { var alertIndex = ((List <UserAlert>)list.Alerts).IndexOf(repoUserAlert); ((List <UserAlert>)list.Alerts).RemoveAt(alertIndex); await this._listRepository.UpdateAsync(list); } }
public async void OnCheckUser(object argParam) { try { var lcManager = App.CenteralIOC.Resolve <IUserManager>(); var lcQuestionAnswer = await lcManager.fnGetSecretQuestionAsync(this.Model.Username); this.Model.SecretQuestion = lcQuestionAnswer; } catch (Exception ex) { UserAlert.fnInformUser(UserInformType.Error, "Error", ex.Message); } }
public async Task <UserAlert> InsertAsync(string userId, UserAlert data) { data.Id = ObjectId.GenerateNewId().ToString(); data.LastModifiedAt = DateTime.UtcNow; var repoUser = await this._userRepository.GetAsync(userId); repoUser.Alerts.Add(data); await this._userRepository.UpdateAsync(userId, repoUser); var createdAlert = await this.GetAsync(userId, data.Id); return(createdAlert); }
private void imgAddGroup_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var lcTitle = UserAlert.fnGetInputFromUser("Insert Reminder Group", "Type group name."); if (string.IsNullOrEmpty(lcTitle)) { return; } var lcDetail = UserAlert.fnGetInputFromUser("Insert Reminder Group", "Type group detail."); if (string.IsNullOrEmpty(lcDetail) || string.IsNullOrEmpty(lcTitle)) { return; } this.mViewModel.fnAddGroupAsync(lcTitle, lcDetail); }
public async Task <JsonResult> ToggleNSFW(int id) { var userId = User.Identity.GetUserId(); using (var db = new ZapContext()) { var post = db.Posts .Include("UserId") .FirstOrDefault(p => p.PostId == id); if (post == null) { return(Json(new { Result = "Error" }, JsonRequestBehavior.AllowGet)); } if (post.UserId.AppId == userId || UserManager.IsInRole(userId, "Administrator") || post.UserId.GroupModeration.Select(g => g.GroupId).Contains(post.Group.GroupId)) { post.IsNSFW = !post.IsNSFW; // Alert the post owner var postOwner = post.UserId; // Add Alert var alert = new UserAlert() { TimeStamp = DateTime.Now, Title = (post.IsNSFW ? "Your post has been marked NSFW : " : "Your post is no longer marked NSFW : ") + post.PostTitle, Content = "A moderator has changed the Not Safe For Work status of your post.", IsDeleted = false, IsRead = false, To = postOwner, PostLink = post, }; postOwner.Alerts.Add(alert); await db.SaveChangesAsync(); return(Json(new { Result = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Result = "Error" }, JsonRequestBehavior.AllowGet)); } } }
/// <summary> /// /// </summary> /// <param name="userIdFollowed"></param> /// <param name="userIdFollowing"></param> /// <param name="isTest"></param> /// <returns></returns> public bool AlertUserNewFollower(int userIdFollowed, int userIdFollowing, bool isTest = false) { using (var db = new ZapContext()) { var userInfo = db.Users .Where(u => u.Id == userIdFollowed) .Select(u => new { u.AppId, User = u }) .FirstOrDefault(); var otherUserInfo = db.Users .Where(u => u.Id == userIdFollowing) .Select(u => new { u.AppId, u.Name }) .FirstOrDefault(); if (userInfo != null && otherUserInfo != null) { UserAlert alert = new UserAlert() { TimeStamp = DateTime.Now, Title = "<a href=" + "/user/" + HttpUtility.UrlEncode(otherUserInfo.Name.Trim()) + "/" + ">" + otherUserInfo.Name + "</a> " + "is now following you!", Content = "", CommentLink = null, IsDeleted = false, IsRead = false, To = userInfo.User, PostLink = null, }; userInfo.User.Alerts.Add(alert); db.SaveChanges(); } return(true); } }
public async Task <AlertUseCaseOutput> Execute(AlertUseCaseInput input) { switch (input.AlertAction) { case AlertAction.Subscribe: { UserAlert userAlert = new UserAlert(); userAlert.AlertId = input.AlertDto.AlertId; userAlert.UserId = input.UserId; userAlert.IsEnabled = true; var added = await this._userAlertRepository.AddAsync(userAlert); if (added != null) { var count = await this._unitOfWork.Save(); if (count > 0) { return(new AlertUseCaseOutput(null, true, "Success, Reloading...")); } else { await this._unitOfWork.Undo(); return(new AlertUseCaseOutput(null, false, "Error: UserAlert Save Failed")); } } else { await this._unitOfWork.Undo(); return(new AlertUseCaseOutput(null, false, "Error: Could not add new UserAlert")); } } case AlertAction.UnSubscribe: { return(new AlertUseCaseOutput(null, false, "Error: Action Not available")); } case AlertAction.ToggleEnable: { return(new AlertUseCaseOutput(null, false, "Error: Action Not available")); } default: return(new AlertUseCaseOutput(null, false, "Error: Invalid option, please contact admin")); } }
public async Task SendWatchedListProductEmail(string correspondenceLanguage, decimal oldPrice, decimal newPrice) { var user = new User { Email = "*****@*****.**", FirstName = "Maxime", Settings = new Settings { CorrespondenceLanguage = correspondenceLanguage } }; var listUser = new User { FirstName = "Toto" }; var list = new List { Name = "Legos", Id = "9876" }; var alert = new UserAlert { Id = "123456", Title = "Test Alert", ImageUrl = "https://pricewi.se/images/pricewise-logo.png", BestCurrentDeal = new Deal { ProductId = "Product1", Price = oldPrice, ModifiedAt = DateTime.Today.AddDays(-1) } }; var newBestDealProduct = new MonitoredProduct { Uri = "https://www.amazon.ca/dp/B073W77D5B/" }; var job = this._container.Resolve <AlertUsersJob>(); var emailInformation = job.BuildWatchedListProductEmail(user, list, listUser, alert, newBestDealProduct, newPrice); Console.WriteLine($"Sending email {emailInformation.TemplateName} to user {user.FirstName} for alert {alert.Title}"); var sendEmailTask = await this._emailSender.SendEmail(emailInformation); Assert.NotEmpty(sendEmailTask.MessageID); Assert.NotEmpty(sendEmailTask.TransactionID); }
/// <summary> /// Generate alerts for the weekly review /// </summary> public bool GenerateAlertsForWeeklyReview(int platformId) { InitRepo(); //Get timepstamp for weekly review SubplatformManager platformManager = new SubplatformManager(); SubPlatform platform = platformManager.GetSubPlatform(platformId); if (platform.LastUpdatedWeeklyReview != null && platform.LastUpdatedWeeklyReview > DateTime.Now.AddDays(-7)) { return(false); } platform.LastUpdatedWeeklyReview = DateTime.Now; platformManager.ChangeSubplatform(platform); //Get all users IEnumerable <User> users = userRepo.ReadAllUsersWithAlerts(); if (users == null || users.Count() == 0) { return(false); } //Generate weekly review alerts foreach (User user in users) { UserAlert alert = new UserAlert() { User = user, Subject = "Nieuwe Weekly Review", IsRead = false, TimeStamp = DateTime.Now, AlertType = AlertType.Weekly_Review }; user.Alerts.Add(alert); } //Update database & send emails SendWeeklyReviewEmails(platformId, users.Where(user => user.AlertsViaEmail)); userRepo.UpdateUsers(users); return(true); }
/// <summary> /// /// </summary> /// <param name="groupId"></param> /// <param name="userId"></param> /// <param name="isTest"></param> /// <returns></returns> public bool AlertGroupAdminGranted(int groupId, int userId, bool isTest = false) { using (var db = new ZapContext()) { var groupInfo = db.Groups .Where(g => g.GroupId == groupId) .Select(g => new { g.GroupName }) .FirstOrDefault(); var userInfo = db.Users .Where(u => u.Id == userId) .Select(u => new { User = u }) .FirstOrDefault(); if (groupInfo != null && userInfo != null) { UserAlert alert = new UserAlert() { TimeStamp = DateTime.Now, Title = "Group administration granted", Content = "You have been granted administration priviliages in " + "<a href='/Group/Detail/" + Convert.ToString(groupId) + "/'>" + groupInfo.GroupName + "</a>.", CommentLink = null, IsDeleted = false, IsRead = false, To = userInfo.User, PostLink = null, }; userInfo.User.Alerts.Add(alert); db.SaveChanges(); } return(true); } }
public AlertDto(UserAlert userAlert) { this.IsEnabled = userAlert.IsEnabled; this.AlertType = userAlert.Alert.AlertType; this.AlertId = userAlert.AlertId; switch (userAlert.Alert.AlertType) { case AlertType.IndividualAlert: var individual = (IndividualAlert)userAlert.Alert; var instance = new InstanceDto(individual.PartInstance); this.AlertIdentifier = instance.Name; this.Quantity = instance.Quantity; this.MinQuantity = (individual.PartInstance != null) ? individual.PartInstance.MinQuantity : -1; this.SafeQuantity = (individual.PartInstance != null) ? individual.PartInstance.SafeQuantity : -1; this.PartInstances = new List <InstanceDto>(); this.PartInstances.Add(instance); break; case AlertType.CombinedAlert: var combinedAlert = (CombinedAlert)userAlert.Alert; this.AlertIdentifier = combinedAlert.StockHolder.Name; var stockType = combinedAlert.StockHolder; this.Quantity = stockType.Quantity; this.MinQuantity = stockType.MinQuantity; this.SafeQuantity = stockType.SafeQuantity; this.PartInstances = stockType.PartInstances.Select(partInstance => new InstanceDto(partInstance)).ToList(); break; } if (this.Quantity < this.SafeQuantity) { this.AlertStatus = AlertStatus.StockWarning; } else if (this.Quantity < this.MinQuantity) { this.AlertStatus = AlertStatus.StockAlert; } else { this.AlertStatus = AlertStatus.StockNoAlert; } }
void SetAlarm(UserAlert userAlert) { // start a new thread - so as not to run on the UI thread - keep the UI thread responsive Task.Factory.StartNew(() => { try { // use UserAlert ID (assigned by SQLite) as unique the alarm number for this alarm int alarmNumber = userAlert.UserAlertID; // get no of milliseconds from datetime object // DateTimeOffset should be considered the default date and time type for application development.(MSDN) long MillisesondsOfUserAlertDateTime = new DateTimeOffset(userAlert.DateAndTime).ToUnixTimeMilliseconds(); // set alarm var ringTime = MillisesondsOfUserAlertDateTime; Intent intent = new Intent(this, typeof(Receiver1)); // CONTEXT,PRIVATE REQUEST CODE, INTENT, FLAG PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, alarmNumber, intent, 0); AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService); alarmManager.Set(AlarmType.RtcWakeup, ringTime, pendingIntent); Log.Debug("DEBUG", "\n\n\n\nAlarm set by Alarm Manager - ID: " + alarmNumber.ToString()); } catch { Log.Debug("DEBUG", "Alarm NOT set by Alarm Manager\n\n\n\n"); } Log.Debug("DEBUG", "End Of SetAlarm()\n\n\n\n"); }); // end of thread //// display output for testing - still works //Log.Debug("DEBUG", "\n\nSetAlarm() - UserAlert ID: " + userAlert.UserAlertID.ToString()); //Log.Debug("DEBUG", "\n\nSetAlarm() - UserAlert ToString:\n" + userAlert.ToString()); //Log.Debug("DEBUG", "\n\nSetAlarm() - UserAlert DateTimeObject:\n" + userAlert.DateAndTime.ToString("dd/MM/yyyy")); //Log.Debug("DEBUG", "SetAlarm() - UserAlert DateTimeObject:\n" + userAlert.DateAndTime.ToString("HH:mmtt")); //Log.Debug("DEBUG", "FINISHED\n\n\n"); }
internal EmailInformation BuildPriceChangeEmail(User user, UserAlert alert, MonitoredProduct newBestDealProduct, decimal newBestDealPrice) { var emailInformation = new EmailInformation(); emailInformation.RecipientAddress = user.Email; var productUrl = new Uri(newBestDealProduct.Uri); var manipulatedUrl = this.GetManipulatedUrl(productUrl); var productTitle = GetProductTitle(user, alert); emailInformation.Parameters = new Dictionary <string, string> { { "subject", user.Settings.CorrespondenceLanguage == "en" ? $"Price alert from PriceWise: The price of {productTitle} changed!" : $"Alerte de prix de PriceWise: Le prix de {productTitle} a changé!" }, { "merge_email", user.Email }, { "merge_firstname", user.FirstName ?? string.Empty }, { "merge_productName", alert.Title ?? string.Empty }, { "merge_previousPrice", alert.BestCurrentDeal.Price.ToString(CultureInfo.InvariantCulture) }, { "merge_newPrice", newBestDealPrice.ToString(CultureInfo.InvariantCulture) }, { "merge_alertId", alert.Id }, { "merge_productUrl", manipulatedUrl.AbsoluteUri }, { "merge_productDomain", productUrl.Authority }, { "merge_imageUrl", alert.ImageUrl.IsBase64Url() ? string.Empty : alert.ImageUrl } }; var changeQualifier = "Drop"; if (alert.BestCurrentDeal.Price < newBestDealPrice) { changeQualifier = "Raise"; } emailInformation.TemplateName = $"Price{changeQualifier}_Unsubscribe_{user.Settings.CorrespondenceLanguage}"; return(emailInformation); }
private async Task AlertGroupNewPost(ZapContext db, Group postGroup, Post post) { var subusers = db.Users .Include("Alerts") .Where(u => u.Groups.Select(g => g.GroupId).Contains(postGroup.GroupId)); foreach (var u in subusers) { // Add Alert var alert = new UserAlert() { TimeStamp = DateTime.Now, Title = "New post in subscribed group <a href='" + Url.Action(actionName: "GroupDetail", controllerName: "Group", routeValues: new { id = postGroup.GroupId }) + "'>" + postGroup.GroupName + "</a>", Content = "",// "<a href='" + Url.Action(actionName:"Detail", controllerName: "Post", routeValues: new { post.PostId }) + "'>" + (post.PostTitle != null ? post.PostTitle : "Post") + "</a>", IsDeleted = false, IsRead = false, To = u, PostLink = post, }; u.Alerts.Add(alert); } await db.SaveChangesAsync().ConfigureAwait(true); }
public async void OnResetPassword(object argParam) { try { if (!Model.Password.Equals(Model.ConfirmPassword)) { throw new Exception("The password sould be same!"); } var lcManager = App.CenteralIOC.Resolve <IUserManager>(); var lcUser = await lcManager.fnResetPasswordAsync(Model.Username, Model.SecretAnswer, Model.Password); if (lcUser == null) { throw new Exception("User could not be found!"); } App.CurrentUser = lcUser; NavigationManger.fnNavigateHome(); } catch (Exception ex) { UserAlert.fnInformUser(UserInformType.Error, "Error", ex.Message); } }
public static async Task TestingUserAlerts(int userId, int alertId) { DbContextOptionsBuilder <ManufacturingContext> optionsBuilder = new DbContextOptionsBuilder <ManufacturingContext>(); optionsBuilder.UseSqlServer("server=192.168.0.5;database=manufacturing_inventory_dev;user=aelmendorf;password=Drizzle123!;MultipleActiveResultSets=true"); using var context = new ManufacturingContext(optionsBuilder.Options); Console.WriteLine("Creating User Alerts, Please Wait..."); var user1 = await context.Users.AsNoTracking().Include(e => e.UserAlerts).FirstOrDefaultAsync(e => e.Id == userId); var alert2 = await context.Alerts.AsNoTracking().OfType <CombinedAlert>().FirstOrDefaultAsync(e => e.Id == alertId); UserAlert userAlert1 = new UserAlert(); userAlert1.AlertId = alert2.Id; userAlert1.UserId = user1.Id; userAlert1.IsEnabled = true; context.UserAlerts.Add(userAlert1); await context.SaveChangesAsync(); Console.WriteLine("UserAlert {0},{1} Created", userId, alertId); }