Esempio n. 1
0
        protected async void FormSubmit()
        {
            int.TryParse(ParentId, out int parentId);
            model.ParentId = parentId;

            #region  일 업로드 관련 추가 코드 영역
            if (selectedFiles != null && selectedFiles.Length > 0)
            {
                // 파일 업로드
                var file     = selectedFiles.FirstOrDefault();
                var fileName = "";
                int fileSize = 0;
                if (file != null)
                {
                    fileName = file.Name;
                    fileSize = Convert.ToInt32(file.Size);

                    // 첨부 파일 삭제
                    await FileStorageManager.DeleteAsync(model.FileName, "");

                    // 다시 업로드
                    fileName = await FileStorageManager.UploadAsync(file.Data, file.Name, "", true);

                    model.FileName = fileName;
                    model.FileSize = fileSize;
                }
            }
            #endregion

            await UploadRepositoryAsyncReference.EditAsync(model);

            NavigationManagerReference.NavigateTo("/Uploads");
        }
        public async Task <ActionResult <bool> > Delete(long primaryKey)
        {
            try
            {
                FileStorage currentDeletingObject = new FileStorage()
                {
                    Id = primaryKey
                };

                return(await _fileStorageManager.DeleteAsync(currentDeletingObject));
            }
            catch (Exception apiControllerError)
            {
                _applicationLogTools.LogError(apiControllerError, new Dictionary <string, dynamic> {
                    { "ClassName", "WebApi.FileStorageController" }
                });

                if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").Equals("Development", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(base.StatusCode(500, apiControllerError));
                }
                else
                {
                    return(base.StatusCode(500));
                }
            }
        }
Esempio n. 3
0
        protected async void DeleteClick()
        {
            bool isDelete = await JSRuntime.InvokeAsync <bool>("confirm", $"{Id}번 글을 정말로 삭제하시겠습니까?");

            if (isDelete)
            {
                if (!string.IsNullOrEmpty(model?.FileName))
                {
                    // 첨부 파일 삭제
                    await FileStorageManager.DeleteAsync(model.FileName, "Libraries");
                }

                await UploadRepositoryAsyncReference.DeleteAsync(Id); // 삭제

                NavigationManagerReference.NavigateTo("/Libraries");  // 리스트 페이지로 이동
            }
            else
            {
                await JSRuntime.InvokeAsync <object>("alert", "취소되었습니다.");
            }
        }