Exemple #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));
            }
        }
Exemple #2
0
        private void AttachFile(Attachment attachment, int id, string fileType, string curUserID)
        {
            if (fileType.Equals(Constants.FileTypes.CUSTOMER_AVATAR))
            {
                var model = CustomerService.GetByID(id);
                if (model != null)
                {
                    model.Avatar = attachment;
                    CustomerService.Update(model, curUserID);
                }
            }
            else if (fileType.Equals(Constants.FileTypes.TALENT_AVATAR))
            {
                var model = TalentService.GetByID(id);
                if (model != null)
                {
                    model.Avatar = attachment;
                    TalentService.Update(model, curUserID);
                }
            }
            else if (fileType.Equals(Constants.FileTypes.TALENT_INTRO_VIDEO))
            {
                var model = TalentService.GetByID(id);
                if (model != null)
                {
                    model.IntroVideo = attachment;
                    TalentService.Update(model, curUserID);
                }
            }
            else if (fileType.Equals(Constants.FileTypes.VIDEO_REQUEST_VIDEO))
            {
                origin += "AttachFile";
                TelegramBotService.SendMessage("Uploading video", origin);

                var model = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);
                if (model == null)
                {
                    throw new Exception("Заказ не найден");
                }
                if (!VideoRequestService.IsVideoUploadable(model))
                {
                    throw new Exception("Невозможно загрузить видео");
                }

                model.Video = attachment;
                VideoRequestService.SaveUploadedVideo(model, curUserID);

                var request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);

                var curUser = accountUtil.GetCurrentUser(User);
                if (!curUser.Type.Equals(UserTypesEnum.talent.ToString()))
                {
                    throw new Exception("Вы не являетесь талантом");
                }

                VideoRequestService.ConfirmVideo(request, curUser.ID);

                //cancel hangfire jobs
                //HangfireService.CancelJob(request.RequestAnswerJobID);
                HangfireService.CancelJob(request.VideoJobID);
            }
            //else if (fileType.Equals(Constants.FileTypes.VIDEO_REQUEST_PAYMENT_SCREENSHOT))
            //{
            //    var request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);
            //    if (request != null)
            //    {
            //        if (request.PaymentScreenshot == null)
            //        {
            //            request.PaymentScreenshot = attachment;
            //            VideoRequestService.SaveUploadedPaymentScreenshot(request, curUserID);

            //            request.PaymentConfirmationJobID = HangfireService
            //                .CreateJobForVideoRequestPaymentConfirmationDeadline(request, curUserID);
            //        }
            //        else
            //            request.PaymentScreenshot = attachment;

            //        VideoRequestService.Update(request, curUserID);
            //    }
            //}
            //else if () ...
        }