コード例 #1
0
ファイル: MaterialsService.cs プロジェクト: why-7/Matbox
        public async Task <string> AddNewMaterial(FilesDto dto)
        {
            if (_dbService.GetCountOfMaterials(dto.uploadedFile.FileName) > 0)
            {
                throw new MaterialAlredyInDbException("Material " + dto.uploadedFile.FileName +
                                                      " is already in the database.");
            }

            if (Enum.IsDefined(typeof(Categories), dto.category) == false)
            {
                throw new WrongCategoryException("Wrong category. Use: Presentation, App, Other");
            }

            await _dbService.AddNewMaterialToDb(dto, GenRandomNameInLocalStorage());

            return("Material " + dto.uploadedFile.FileName + " was created");
        }