コード例 #1
0
        public IActionResult Cancel(int id)
        {
            origin += "Cancelling";
            TelegramBotService.SendMessage("Cancelling video request", origin);
            try
            {
                var request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);
                if (request == null)
                {
                    //return NotFound();
                    throw new Exception("Заказ не найден");
                }

                var curUser = accountUtil.GetCurrentUser(User);

                //cancel request/video
                VideoRequestService.Cancel(request, curUser.ID, curUser.Type);

                //cancel hangfire jobs
                //HangfireService.CancelJob(request.RequestAnswerJobID);
                HangfireService.CancelJob(request.VideoJobID);

                TelegramBotService.SendMessage("Cancelled video request", origin);
                return(Ok());
            }
            catch (Exception ex)
            {
                TelegramBotService.SendMessage(ex.Message, origin);
                return(CustomBadRequest(ex));
            }
        }