Пример #1
0
        public async Task NotifyAsync(int notificationId, CancellationToken cancellationToken)
        {
            var notification = await _eventNotificationService.GetByIdAsync(notificationId);

            if (notification == null)
            {
                _logger.LogError($"Scheduled notification with Id {notificationId} is not found in database");
                return;
            }

            try
            {
                var chatId = new ChatId(notification.UserTelegramId);
                var msg    = await _botClient.SendTextMessageAsync(chatId, notification.Subject, cancellationToken : cancellationToken);

                _logger.LogDebug($"Sended scheduled notification {notificationId}");

                await _eventNotificationService.DeleteAsync(notificationId);

                _logger.LogDebug($"Deleted scheduled notification {notificationId}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error sending notification {notificationId}");
                throw;
            }
        }
        public virtual async Task <TDto> DeleteAsync(TId id)
        {
            var deletedEntity = await _service.DeleteAsync(id);

            await _repository.SaveChangesAsync();

            return(_mapper.Map <TDto>(deletedEntity));
        }
Пример #3
0
        public async Task DeleteOrderStatusAsync(int orderId)
        {
            var orderStatus = await orderStatusService.Where(item => item.OrderId == orderId).ToListAsync();

            foreach (var status in orderStatus)
            {
                await orderStatusService.DeleteAsync(status);
            }
        }
Пример #4
0
        public async Task DeleteOrderPositionAsync(int orderId)
        {
            var orderPositions = await orderPositionService.Where(op => op.OrderId == orderId).ToArrayAsync();

            foreach (var orderPosition in orderPositions)
            {
                await orderPositionService.DeleteAsync(orderPosition);
            }
        }
Пример #5
0
        public async Task <IActionResult> DeleteAsync(int id)
        {
            if (DeleteWhere(id) != null)
            {
                var result = await _crudService.DeleteAsync(DeleteWhere(id));

                return(Json(result));
            }
            return(Json(Result.Create(true, 200)));
        }
Пример #6
0
        public async Task <IHttpActionResult> DeleteCommentAsync(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            await _commentService.DeleteAsync(id);

            return(Ok());
        }
Пример #7
0
 public virtual async Task <ActionResult <T2> > Delete(T1 id)
 {
     try
     {
         return(Ok(await _service.DeleteAsync(id)));
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
 }
        public async Task DeleteIngredientsAsync(int productId)
        {
            var productIngredients = await m_productIngredientService
                                     .Where(item => item.ProductId == productId)
                                     .ToListAsync();

            foreach (var item in productIngredients)
            {
                await m_productIngredientService.DeleteAsync(item);
            }
        }
Пример #9
0
 public async Task <IActionResult> Delete(Guid id)
 {
     try
     {
         return(Ok(await _service.DeleteAsync(id)));
     }
     catch (EntityNotFoundException ex)
     {
         return(NotFound());
     }
 }
Пример #10
0
        public async Task <IActionResult> Delete(int id)
        {
            if (await _service.ReadAsync(id) == null)
            {
                _logger.LogInformation($"{nameof(OrdersController)}:{id} not found");
                return(NotFound());
            }

            await _service.DeleteAsync(id);

            return(NoContent());
        }
        public virtual async Task <CustomerOrderAggregate> Handle(CreateOrderFromCartCommand request, CancellationToken cancellationToken)
        {
            var cart = await _cartService.GetByIdAsync(request.CartId);

            await ValidateCart(cart);

            var result = await _customerOrderAggregateRepository.CreateOrderFromCart(cart);

            await _cartService.DeleteAsync(new List <string> {
                request.CartId
            }, softDelete : true);

            // Remark: There is potential bug, because there is no transaction thru two actions above. If a cart deletion fails, the order remains. That causes data inconsistency.
            // Unfortunately, current architecture does not allow us to support such scenarios in a transactional manner.
            return(result);
        }
        /// <summary>
        /// Deletes the asynchronous.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public virtual async Task <T2> DeleteAsync(T1 id)
        {
            var entity = await _service.DeleteAsync(id);

            // store all object in historical event
            var historicalEvent = new HistoricalEvent
            {
                Action    = HistoricalActions.Delete.ToString(),
                Changeset = new HistoricalChangeset()
                {
                    ObjectData = new T2().DetailedCompare(entity)
                },
                EntityId   = entity.Id.ToString(),
                EntityName = entity.GetType().FullName
            };
            await _repository.CreateAsync <Guid, HistoricalEvent>(historicalEvent);

            await _repository.SaveChangesAsync();

            return(entity);
        }
Пример #13
0
        public async Task <ActionResult <CourseDTO> > DeleteCourse(int id)
        {
            try
            {
                var exist = await _crudService.AnyAsync <Course>(s => s.Id.Equals(id));

                if (!exist)
                {
                    return(NotFound("Unable to find the related entity"));
                }

                if (await _crudService.DeleteAsync <Course>(i => i.Id.Equals(id)))
                {
                    return(NoContent());
                }
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Failed to add the entity"));
            }

            return(BadRequest("Cannot delete this item!"));
        }
Пример #14
0
        public async Task <IActionResult> DeleteAsync(int id, CancellationToken cancellationToken = default)
        {
            await _crudService.DeleteAsync(id);

            return(NoContent());
        }
Пример #15
0
        public async Task <ActionResult> DeleteAsync(Guid id)
        {
            await _studentCrudService.DeleteAsync(id);

            return(Ok());
        }
Пример #16
0
        public async Task <ActionResult> Delete([FromQuery] string[] ids)
        {
            await _customerReviewService.DeleteAsync(ids);

            return(NoContent());
        }
Пример #17
0
 public virtual Task RemoveCartAsync(string cartId) => _shoppingCartService.DeleteAsync(new[] { cartId }, softDelete: true);
Пример #18
0
 public async Task HandleAsync(DeleteEntityCommand <TEntity> command)
 {
     await _crudService.DeleteAsync(command.Entity);
 }
Пример #19
0
 public async Task <T2> DeleteAsync(T1 id) => await _service.DeleteAsync(id);
Пример #20
0
 public async Task Delete([FromRoute] string id)
 => await _service.DeleteAsync(id);
 public async Task HandleAsync(DeleteEntityCommand <TEntity> command, CancellationToken cancellationToken = default)
 {
     await _crudService.DeleteAsync(command.Entity);
 }
Пример #22
0
 public virtual async Task <T> DeleteAsync(Guid id) => await _service.DeleteAsync(id);
Пример #23
0
 public async Task HandleAsync(DeleteProductCommand command, CancellationToken cancellationToken = default)
 {
     await _productService.DeleteAsync(command.Product);
 }
Пример #24
0
 public async Task HandleAsync(DeleteProductCommand command)
 {
     await _productService.DeleteAsync(command.Product);
 }
Пример #25
0
        public virtual async Task <IActionResult> DeleteAsync(string id)
        {
            await _service.DeleteAsync(id);

            return(Success());
        }
Пример #26
0
 public async Task <IHttpActionResult> DeleteAsync([FromUri] Guid id) => await ExecuteAsync(async() => await _crudService.DeleteAsync(id));