public ActionResult <string> ReceiveFile([FromForm] AnimalInput data)
        {
            //var animal = _animalService.Get();
            var status = "";
            var result = _animalService.Overlap(data.ThaiName);

            if (result == null)
            {
                var newTaxonomy = new Taxonomy()
                {
                    Kingdom      = data.Kingdom,
                    Phylum       = data.Phylum,
                    SubPhylum    = data.SubPhylum,
                    InfraPhylum  = data.InfraPhylum,
                    Class        = data.Class,
                    SubClass     = data.SubClass,
                    InfraClass   = data.InfraClass,
                    Order        = data.Order,
                    SubOrder     = data.SubOrder,
                    InfraOrder   = data.InfraOrder,
                    Family       = data.Family,
                    SubFamily    = data.SubFamily,
                    InfraFamily  = data.InfraFamily,
                    Genus        = data.Genus,
                    SubGenus     = data.SubGenus,
                    InfraGenus   = data.InfraGenus,
                    Species      = data.Species,
                    SubSpecies   = data.SubSpecies,
                    InfraSpecies = data.InfraSpecies,
                };
                _taxonomyService.Create(newTaxonomy);

                var newAnimal = new Animal()
                {
                    TaxonomyId     = newTaxonomy.Id,
                    ThaiName       = data.ThaiName,
                    CommonName     = data.CommonName,
                    ScientificName = data.ScientificName,
                    Description    = data.Description,
                    BoneImgPath    = data.BoneImgPath,
                    ImgPath        = data.ImgPath,
                };

                status = "Upload Success";

                _animalService.Create(newAnimal);
            }
            else
            {
                status = "name already exists!";
            }
            return(status);
        }
Example #2
0
        public ActionResult <Animal> Create(Animal animal)
        {
            _animalService.Create(animal);

            return(CreatedAtRoute("GetAnimal", new { id = animal.Id.ToString() }, animal));
        }