Exemplo n.º 1
0
        public async Task <PartialViewResult> CreateOrEditModal(int id)
        {
            if (id != 0)
            {
                var output = await _mpMediaVoiceAppService.Get(new EntityDto <int>(id));

                var viewModel = new CreateOrEditMpMediaVoiceViewModel(output);
                return(PartialView("_CreateOrEditModal", viewModel));
            }
            else
            {
                var mpID = await _userMpAppService.GetDefaultMpId();

                var model = new CreateOrEditMpMediaVoiceViewModel()
                {
                    MpID = mpID, MediaID = ""
                };
                return(PartialView("_CreateOrEditModal", model));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Download(string mediaType, int id)
        {
            var    tempProfilePicturePath = "";
            string contentType            = "";

            if (mediaType == MpMessageType.video.ToString())
            {
                var data = await _mpMediaVideoAppService.Get(new Abp.Application.Services.Dto.EntityDto <int> {
                    Id = id
                });

                tempProfilePicturePath = data.FileID;
                var extraFileType = tempProfilePicturePath.Substring(tempProfilePicturePath.LastIndexOf(".") + 1);
                if (extraFileType == "mp4")
                {
                    contentType = "video/mpeg4";
                }
                else if (extraFileType == "rmvb")
                {
                    contentType = "application/vnd.rn-realmedia-vbr";
                }
                else if (extraFileType == "avi")
                {
                    contentType = "video/avi";
                }
                else if (extraFileType == "mpg" || extraFileType == "mpeg")
                {
                    contentType = "video/mpg";
                }
                else
                {
                    contentType = "application/file";
                }
            }
            if (mediaType == MpMessageType.voice.ToString())
            {
                var data = await _mpMediaVoiceAppService.Get(new Abp.Application.Services.Dto.EntityDto <int> {
                    Id = id
                });

                tempProfilePicturePath = data.FileID;
                var extraFileType = tempProfilePicturePath.Substring(tempProfilePicturePath.LastIndexOf(".") + 1);
                if (extraFileType == "mp3")
                {
                    contentType = "audio/mp3";
                }
                else if (extraFileType == "wma")
                {
                    contentType = "audio/x-ms-wma";
                }
                else if (extraFileType == "wav")
                {
                    contentType = "	audio/wav";
                }
                else
                {
                    contentType = "application/file";
                }
            }

            if (!string.IsNullOrWhiteSpace(tempProfilePicturePath))
            {
                var imgStream = new MemoryStream(System.IO.File.ReadAllBytes(tempProfilePicturePath));
                return(File(imgStream, contentType));
            }
            else
            {
                return(null);
            }
        }