Ejemplo n.º 1
0
        public IActionResult ConfirmVideo(int request_id)
        {
            try
            {
                var request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(request_id);
                if (request == null)
                {
                    throw new Exception("Заказ не найден");
                }

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

                //int balance = TalentBalanceService.GetBalance(request.Talent);
                //if (balance <= 0)
                //    throw new Exception("У Вас недостаточно средств, чтобы подтвердить запрос");

                //confirm request/video
                VideoRequestService.ConfirmVideo(request, curUser.ID);

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

                ////create hangfire PaymentReminderJobID
                //HangfireService.CreateJobForPaymentReminder(model, curUser.ID);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(CustomBadRequest(ex));
            }
        }
Ejemplo n.º 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 () ...
        }