Пример #1
0
 public IActionResult AddMaterial([FromForm] NewMaterialDto material, [FromForm] IFormFile file)
 {
     if (material.Name != null && file != null
         && file.Length < _configuration.GetValue<long>("Size"))
     {
         Material newMaterial = new Material { Name = material.Name, Category = material.Category, Extension = file.FileName.Split(".").Last() };
         var result = _materialService.AddMaterial(newMaterial, file);
         if (result != null)
             return Ok();
     }
     return BadRequest("Материал с данным именем уже существует");
 }
Пример #2
0
 public IActionResult AddMaterial([FromForm] NewMaterialDto material)
 {
     if (material.Name != null && material.Category != null && material.File != null &&
         material.File.Length < 2147483648 && Categories.Contains(material.Category))
     {
         Material newMaterial = new Material {
             Name = material.Name, Category = material.Category
         };
         var result = _materialService.AddMaterial(newMaterial, material.File);
         if (result != null)
         {
             return(Ok());
         }
     }
     return(BadRequest());
 }
Пример #3
0
 public IActionResult AddMaterial([FromForm] NewMaterialDto material)
 {
     if (material.Name != null && material.Category != null && material.File != null &&
         material.File.Length < _fileSizeLimit && (Enum.IsDefined(typeof(MaterialCategories), material.Category)))
     {
         Material newMaterial = new Material
         {
             Name     = material.Name,
             Category = material.Category
         };
         var result = _materialService.AddMaterial(newMaterial, material.File);
         if (result != null)
         {
             return(Ok());
         }
     }
     return(BadRequest());
 }