Exemple #1
0
        public async Task <NotificationViewModel> DismissNotification(DismissNotificationRequest request)
        {
            CheckNotificationExists(request.Id);
            var notification = _context.Notifications.First(x => x.Id == request.Id);

            notification.IsDismissed = true;
            await _context.SaveChangesAsync();

            return(new NotificationViewModel()
            {
                Id = request.Id,
                Title = notification.Title,
                Message = notification.Text,
                IsDismissed = notification.IsDismissed.Value
            });
        }
Exemple #2
0
        public async Task <TodoViewModel> AddTodo(AddTodoRequest request)
        {
            var todo = new Todo()
            {
                UserId      = request.UserId, Title = request.Title, Text = request.Text, TargetDate = request.TargetDate,
                CreatedDate = DateTime.UtcNow
            };
            await _context.Todos.AddAsync(todo);

            await _context.SaveChangesAsync();

            return(new TodoViewModel()
            {
                Id = todo.Id,
                Text = todo.Text,
                Title = todo.Title,
                CreatedDate = todo.CreatedDate,
                TargetDate = todo.TargetDate
            });
        }