public async Task <ActionResult <object> > DeleteTelegramBotUpdate(int id) { TelegramBotUpdateObjectModel telegramBotUpdate = await _context.TelegramBotUpdates.FindAsync(id); if (telegramBotUpdate == null) { _logger.LogError("Удаление TelegramBot Update невозможно. Объект не найден"); return(new ObjectResult(new ServerActionResult() { Success = false, Info = "TelegramBot Update не найден", Status = StylesMessageEnum.danger.ToString() })); } _context.TelegramBotUpdates.Remove(telegramBotUpdate); await _context.SaveChangesAsync(); _logger.LogInformation("TelegramBot Update удалён: id={0}", id); return(new ObjectResult(new ServerActionResult() { Success = true, Info = "TelegramBot Update удалён", Status = StylesMessageEnum.success.ToString() })); }
public async Task <ActionResult <object> > GetTelegramBotUpdate(int id) { TelegramBotUpdateObjectModel telegramBotUpdate = await _context.TelegramBotUpdates .Include(x => x.User).ThenInclude(x => x.Avatar) .Include(x => x.User).ThenInclude(x => x.Department) .FirstOrDefaultAsync(x => x.Id == id); if (telegramBotUpdate == null) { _logger.LogError("Запрошеный TelegramBot Update не найден по ключу: {0}", id); return(new ObjectResult(new ServerActionResult() { Success = false, Info = "TelegramBot Update не найден: id=" + id, Status = StylesMessageEnum.warning.ToString() })); } return(new ObjectResult(new ServerActionResult() { Success = true, Info = "Запрос успешно обработан. TelegramBot Update найден. ", Status = StylesMessageEnum.success.ToString(), Tag = new { telegramBotUpdate.Id, telegramBotUpdate.DateCreate, telegramBotUpdate.Name, telegramBotUpdate.Information, telegramBotUpdate.isBotMessage, User = new { telegramBotUpdate.User.Id, telegramBotUpdate.User.Name, telegramBotUpdate.User.Information, telegramBotUpdate.User.isDisabled, telegramBotUpdate.User.LastTelegramVisit, telegramBotUpdate.User.LastWebVisit, telegramBotUpdate.User.isReadonly, Role = telegramBotUpdate.User.Role.ToString(), Avatar = new { telegramBotUpdate.User.Avatar.Id, telegramBotUpdate.User.Avatar.Name, telegramBotUpdate.User.Avatar.Information }, Department = new { telegramBotUpdate.User.Department.Id, telegramBotUpdate.User.Department.Name, telegramBotUpdate.User.Department.Information } } } })); }