コード例 #1
0
        public ActionResult <VideoRequestDetailsForCustomerVM> Details(int id)
        {
            try
            {
                var          curUser = accountUtil.GetCurrentUser(User);
                VideoRequest request = VideoRequestService.GetActiveSingleDetailsWithRelatedDataByID(id);

                if (request == null || !VideoRequestService.BelongsToCustomer(request, curUser.ID))
                {
                    throw new Exception("Ваш заказ не найден");
                }

                if (request.ViewedByCustomer == false)
                {
                    request.ViewedByCustomer = true;
                    VideoRequestService.Update(request, curUser.ID);
                }

                var requestVM = new VideoRequestDetailsForCustomerVM(request);
                requestVM.edit_btn_is_available   = VideoRequestService.IsEditable(request);
                requestVM.cancel_btn_is_available = VideoRequestService.IsCancelable(request);

                //requestVM.request_price = VideoRequestPriceCalculationsService.CalculateRequestPrice(request);
                //requestVM.RequestPriceToStr();

                //requestVM.remaining_price = VideoRequestPriceCalculationsService.CalculateRemainingPrice(request.Price, request.WebsiteCommission);
                //requestVM.RemainingPriceToStr();

                requestVM.video_is_confirmed = VideoRequestService.IsVideoConfirmed(request);
                //requestVM.payment_screenshot_is_uploaded = VideoRequestService.IsPaymentScreenshotUploaded(request);

                //requestVM.payment_is_confirmed = VideoRequestService.IsPaymentConfirmed(request);
                if (requestVM.video_is_confirmed)
                {
                    //requestVM.video = new AttachmentDetailsVM(request.Video);
                    requestVM.video = AttachmentDetailsVM.ToVM(request.Video);
                }

                if (requestVM.edit_btn_is_available)
                {
                    requestVM.video_request_edit_vm = new VideoRequestEditVM(request);
                    requestVM.video_request_edit_vm.video_request_types = VideoRequestTypeService.GetAsSelectList();
                }

                //VideoRequestEditVM editModelVM = new VideoRequestEditVM(request);

                return(requestVM);
            }
            catch (Exception ex)
            {
                return(CustomBadRequest(ex));
            }
        }