示例#1
0
        public IActionResult OnGetCreate()
        {
            var command = new CreateMultimedia
            {
                Ceremonies = _ceremonyApplication.GetCeremonies()
            };

            return(Partial("./Create", command));
        }
        public OperationResult Create(CreateMultimedia command, List <IFormFile> files)
        {
            var operation = new OperationResult();

            if (_multimediaRepository.Exist(x => x.Title == command.Title))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }
            var ceremony = _ceremonyRepository.GetDetail(command.CeremonyId);

            foreach (var item in files)
            {
                var ImageFolderName = Tools.ToFolderName(this.GetType().Name);
                var ImagePath       = $"{ImageFolderName}/{ceremony.Slug}";
                var imageFileName   = _fileUploader.Upload(item, ImagePath);
                var multimedia      = new Multimedia(ceremony.Title, imageFileName, command.FileTitle, command.FileAlt, command.CeremonyId);
                _multimediaRepository.Create(multimedia);
            }

            _multimediaRepository.SaveChanges();
            return(operation.Succedded());
        }
示例#3
0
        public JsonResult OnPostCreate(CreateMultimedia createcommand, List <IFormFile> FileAddress)
        {
            var result = _multimediaApplication.Create(createcommand, FileAddress);

            return(new JsonResult(result));
        }