public async Task <IReadOnlyList <NotificationDto> > SearchListAsync(Guid userId, string moduleCode, NotificationActionTypes actionType) { using (_dbContextScopeFactory.CreateReadOnly()) { var minDate = DateTime.Now.AddDays(-14); if (string.IsNullOrEmpty(moduleCode)) { return(await _notificationRepository .GetAll() .Where(w => !w.IsDeleted && w.CreatedDate >= minDate && w.RecipientId == userId && w.NotificationType.ActionType == actionType) .OrderByDescending(w => w.CreatedDate) .ProjectTo <NotificationDto>(_mapper.ConfigurationProvider) .ToListAsync()); } return(await _notificationRepository .GetAll() .Where(w => !w.IsDeleted && w.CreatedDate >= minDate && w.RecipientId == userId && w.ModuleCode.Equals(moduleCode, StringComparison.OrdinalIgnoreCase) && w.NotificationType.ActionType == actionType) .OrderByDescending(w => w.CreatedDate) .ProjectTo <NotificationDto>(_mapper.ConfigurationProvider) .ToListAsync()); } }
public async Task <IReadOnlyList <NotificationDto> > GetMessagesAsync(Guid userId, NotificationActionTypes actionType) { using (_dbContextScopeFactory.CreateReadOnly()) { var models = await _notificationRepository.GetByUser(userId, actionType); return(_mapper.Map <List <NotificationDto> >(models)); } }
public async Task <List <Notification> > GetByUser(Guid userId, NotificationActionTypes actionType) { var getDate = DateTime.Now.AddDays(-14); return(await DbSet.AsNoTracking().Include(i => i.NotificationType) .OrderBy(o => o.ModuleCode).ThenByDescending(t => t.CreatedDate) .Where(w => !w.IsDeleted && w.CreatedDate >= getDate && w.RecipientId == userId && w.NotificationType.ActionType == actionType) .ToListAsync()); }
public void Update(string name, string description, string template, string moduleCode, NotificationActionTypes actionType) { ModifiedDate = DateTime.Now; Name = name; Description = description; Template = template; ActionType = actionType; ActionTypeName = actionType.ToString(); ModuleCode = moduleCode; }
public static NotificationType Create(string name, string description, string template, string moduleCode, NotificationActionTypes actionType) { return(new NotificationType() { ActionType = actionType, ActionTypeName = actionType.ToString(), Name = name, Description = description, IsDeleted = false, Template = template, ModuleCode = moduleCode }); }
public async Task <List <Notification> > GetListAsync(Guid userId, string moduleCode, NotificationActionTypes actionType) { var getDate = DateTime.Now.AddDays(-14); return(await DbSet.AsNoTracking() .Include(i => i.NotificationType) .OrderBy(t => t.CreatedDate) .Where(w => !w.IsDeleted && w.CreatedDate >= getDate && w.RecipientId == userId && w.ModuleCode.Equals(moduleCode, StringComparison.OrdinalIgnoreCase) && w.NotificationType.ActionType == actionType) .ToListAsync()); }
public async Task <JsonResult> Search(string moduleCode, NotificationActionTypes actionType) { var messages = await _notificationServices.SearchListAsync(CurrentUser.Id, moduleCode, actionType); return(Json(messages, JsonRequestBehavior.AllowGet)); }
public async Task <MobileResponse <IReadOnlyList <NotificationDto> > > Search(NotificationActionTypes actionType, string moduleCode) { try { var result = await _notificationServices.SearchListAsync(CurrentUser.Id, moduleCode, actionType); return(MobileResponse <IReadOnlyList <NotificationDto> > .Create(MobileStatusCode.Success, null, result)); } catch (Exception ex) { _loggerServices.WriteError(ex.ToString()); return(MobileResponse <IReadOnlyList <NotificationDto> > .Create(MobileStatusCode.Error, ex.ToString(), null)); } }