public virtual async Task <int> AddAsync(TblUserMessages record) { _dbContext.UserMessages.Add(record); await _dbContext.SaveChangesAsync(); QueryCacheManager.ExpireTag(CacheTags.UserMessages); _eventPublisher.EntityInserted(record); //Send Notification to admin var urlHelper = new UrlHelper(_httpContext.Request.RequestContext); var messageUrl = urlHelper.Action("ReplyToUserMessage", "ManageUserMessages", new { id = record.Id, area = "Admin" }, _httpContext.Request.Url.Scheme); if (!_workContext.IsAdmin) { //Notification to admin await _notificationsService.SendNotificationAsync("Admin", "Notification_NewUserMessage", new { Name = record.Name, Email = record.Email, Url = messageUrl }); } //-------------- return(record.Id); }
public virtual async Task UpdateAsync(TblUserMessages record) { var oldRecord = await FindByIdAsync(record.Id); _dbContext.UserMessages.AddOrUpdate(record); await _dbContext.SaveChangesAsync(); QueryCacheManager.ExpireTag(CacheTags.UserMessages); _eventPublisher.EntityUpdated(record, oldRecord); }
public virtual ReplyToUserMessageModel PrepareReplyToUserMessageModel(TblUserMessages message) { var result = message == null ? new ReplyToUserMessageModel() : message.Adapt <ReplyToUserMessageModel>(); var userMessage = HttpUtility.HtmlEncode(result.Message); userMessage = userMessage.Replace("\r\n", "\r"); userMessage = userMessage.Replace("\n", "\r"); userMessage = userMessage.Replace("\r", "<br/>\r\n"); userMessage = userMessage.Replace(" ", " "); result.Message = userMessage; if (string.IsNullOrWhiteSpace(result.ResponseText)) { result.ResponseText = $"<div style='direction: {(result.Message.IsRtlLanguage() ? "rtl" : "ltr")}'><p><br/></p><hr/><small><blockquote>{userMessage}</blockquote></small></div>"; } return(result); }