コード例 #1
0
        public static SpiderModel ConvertSpiderToModel(SpiderAnimalTaxonomyView result)
        {
            var spiderModel = new SpiderModel
            {
                NamePl           = result.Spider.NamePl,
                NameEng          = result.Spider.NameEng,
                Size             = result.Spider.Size,
                Type             = result.Spider.Type,
                TemperatureMin   = result.Spider.TemperatureMin,
                TemperatureMax   = result.Spider.TemperatureMax,
                HumidityMin      = result.Spider.HumidityMin,
                HumidityMax      = result.Spider.HumidityMax,
                OriginPlace      = result.Spider.OriginPlace,
                PowerOfVenom     = result.Spider.PowerOfVenom,
                Aggressiveness   = result.Spider.Aggressiveness,
                Speed            = result.Spider.Speed,
                LengthOfLife     = result.Spider.LengthOfLife,
                CocoonSize       = result.Spider.CocoonSize,
                Description      = result.Spider.Description,
                Experience       = result.Spider.Experience,
                ShortDescription = result.Spider.ShortDescription
                                   //AnimalTaxonomyId = result.Spider.AnimalTaxonomyId
            };



            return(spiderModel);
        }
コード例 #2
0
        public async Task <IActionResult> Edit(SpiderAnimalTaxonomyView result)
        {
            var spiderModel = await _spiderService.Get(result.Spider.Id);

            var animalTaxonomyModel = await _animalTaxonomyService.Get(spiderModel.AnimalTaxonomyId);

            var spiderUpdateModel         = SpiderHelpers.MergeSpiderModelWitthView(spiderModel, result);
            var animalTaxonomyUpdateModel = SpiderHelpers.MergeAnimalTaxonomyModelWithView(animalTaxonomyModel, result);

            if (result.Spider.SpiderFileImg != null)
            {
                if (spiderModel.Image != null)
                {
                    _cloudinaryService.DeleteSpiderImage(spiderModel.Image.Id);
                }
                await _cloudinaryService.AddSpiderImage(result.Spider.SpiderFileImg, spiderModel.Id);
            }

            await _spiderService.Update(spiderUpdateModel, animalTaxonomyUpdateModel);

            return(RedirectToAction("List"));
        }
コード例 #3
0
        public static AnimalTaxonomyModel ConvertAnimalTaxonomyToModel(SpiderAnimalTaxonomyView result)
        {
            var AnimalTaxonomyModel = new AnimalTaxonomyModel
            {
                Regnum       = result.AnimalTaxonomy.Regnum,
                Subregnum    = result.AnimalTaxonomy.Subregnum,
                Superphylum  = result.AnimalTaxonomy.Superphylum,
                Phylum       = result.AnimalTaxonomy.Phylum,
                Subphylum    = result.AnimalTaxonomy.Subphylum,
                Infraphylum  = result.AnimalTaxonomy.Infraphylum,
                Superclassis = result.AnimalTaxonomy.Superclassis,
                Classis      = result.AnimalTaxonomy.Classis,
                Subclassis   = result.AnimalTaxonomy.Subclassis,
                Infraclassis = result.AnimalTaxonomy.Infraclassis,
                Superordo    = result.AnimalTaxonomy.Superordo,
                Ordo         = result.AnimalTaxonomy.Ordo,
                Subordo      = result.AnimalTaxonomy.Subordo,
                Infraordo    = result.AnimalTaxonomy.Infraordo,
                Superfamilia = result.AnimalTaxonomy.Superfamilia,
                Familia      = result.AnimalTaxonomy.Familia,
                Subfamilia   = result.AnimalTaxonomy.Subfamilia,
                Infrafamilia = result.AnimalTaxonomy.Infrafamilia,
                Supertrubus  = result.AnimalTaxonomy.Supertrubus,
                Tribus       = result.AnimalTaxonomy.Tribus,
                Subtribus    = result.AnimalTaxonomy.Subtribus,
                Infratribus  = result.AnimalTaxonomy.Infratribus,
                Supergenus   = result.AnimalTaxonomy.Supergenus,
                Genus        = result.AnimalTaxonomy.Genus,
                Subgenus     = result.AnimalTaxonomy.Subgenus,
                Infragenus   = result.AnimalTaxonomy.Infragenus,
                Species      = result.AnimalTaxonomy.Species,
                Subspecies   = result.AnimalTaxonomy.Subspecies,
                Natio        = result.AnimalTaxonomy.Natio,
                Morpha       = result.AnimalTaxonomy.Morpha,
                Forma        = result.AnimalTaxonomy.Forma
            };

            return(AnimalTaxonomyModel);
        }
コード例 #4
0
        public async Task <IActionResult> Add(SpiderAnimalTaxonomyView result)
        {
            if (!ModelState.IsValid)
            {
                ViewData["AnimalTaxonomy"] = await _animalTaxonomyService.GetAll();

                return(View(result));
            }

            var spiderModel = SpiderHelpers.ConvertSpiderToModel(result);

            var animalTaxonomyModel = SpiderHelpers.ConvertAnimalTaxonomyToModel(result);

            await _animalTaxonomyService.Create(animalTaxonomyModel);

            var animalTaxonomyId = animalTaxonomyModel.Id;

            await _spiderService.Create(spiderModel, animalTaxonomyId);

            await _cloudinaryService.AddSpiderImage(result.Spider.SpiderFileImg, spiderModel.Id);


            return(RedirectToAction("List"));
        }
コード例 #5
0
        public static SpiderModel MergeSpiderModelWitthView(SpiderModel model, SpiderAnimalTaxonomyView view)
        {
            model.NamePl  = view.Spider.NamePl;
            model.NameEng = view.Spider.NameEng;
            //model.AnimalTaxonomyId = view.Spider.AnimalTaxonomyId;
            model.Size             = view.Spider.Size;
            model.Type             = view.Spider.Type;
            model.TemperatureMin   = view.Spider.TemperatureMin;
            model.TemperatureMax   = view.Spider.TemperatureMax;
            model.HumidityMin      = view.Spider.HumidityMin;
            model.HumidityMax      = view.Spider.HumidityMax;
            model.OriginPlace      = view.Spider.OriginPlace;
            model.PowerOfVenom     = view.Spider.PowerOfVenom;
            model.Aggressiveness   = view.Spider.Aggressiveness;
            model.Speed            = view.Spider.Speed;
            model.LengthOfLife     = view.Spider.LengthOfLife;
            model.CocoonSize       = view.Spider.CocoonSize;
            model.Description      = view.Spider.Description;
            model.ShortDescription = view.Spider.ShortDescription;
            model.Experience       = view.Spider.Experience;


            return(model);
        }
コード例 #6
0
        public static SpiderAnimalTaxonomyView ConvertSpiderAndAnimalTaxonomyToView(SpiderModel spider, AnimalTaxonomyModel animalTaxonomy)
        {
            var spiderAnimalTaxonomyView = new SpiderAnimalTaxonomyView
            {
                Spider = new SpiderView
                {
                    Id               = spider.Id,
                    NamePl           = spider.NamePl,
                    NameEng          = spider.NameEng,
                    Size             = spider.Size,
                    Type             = spider.Type,
                    TemperatureMin   = spider.TemperatureMin,
                    TemperatureMax   = spider.TemperatureMax,
                    HumidityMin      = spider.HumidityMin,
                    HumidityMax      = spider.HumidityMax,
                    OriginPlace      = spider.OriginPlace,
                    PowerOfVenom     = spider.PowerOfVenom,
                    Aggressiveness   = spider.Aggressiveness,
                    Speed            = spider.Speed,
                    LengthOfLife     = spider.LengthOfLife,
                    CocoonSize       = spider.CocoonSize,
                    Description      = spider.Description,
                    Experience       = spider.Experience,
                    ShortDescription = spider.ShortDescription
                },

                AnimalTaxonomy = new AnimalTaxonomyView
                {
                    Id           = animalTaxonomy.Id,
                    Regnum       = animalTaxonomy.Regnum,
                    Subregnum    = animalTaxonomy.Subregnum,
                    Superphylum  = animalTaxonomy.Superphylum,
                    Phylum       = animalTaxonomy.Phylum,
                    Subphylum    = animalTaxonomy.Subphylum,
                    Infraphylum  = animalTaxonomy.Infraphylum,
                    Superclassis = animalTaxonomy.Superclassis,
                    Classis      = animalTaxonomy.Classis,
                    Subclassis   = animalTaxonomy.Subclassis,
                    Infraclassis = animalTaxonomy.Infraclassis,
                    Superordo    = animalTaxonomy.Superordo,
                    Ordo         = animalTaxonomy.Ordo,
                    Subordo      = animalTaxonomy.Subordo,
                    Infraordo    = animalTaxonomy.Infraordo,
                    Superfamilia = animalTaxonomy.Superfamilia,
                    Familia      = animalTaxonomy.Familia,
                    Subfamilia   = animalTaxonomy.Subfamilia,
                    Infrafamilia = animalTaxonomy.Infrafamilia,
                    Supertrubus  = animalTaxonomy.Supertrubus,
                    Tribus       = animalTaxonomy.Tribus,
                    Subtribus    = animalTaxonomy.Subtribus,
                    Infratribus  = animalTaxonomy.Infratribus,
                    Supergenus   = animalTaxonomy.Supergenus,
                    Genus        = animalTaxonomy.Genus,
                    Subgenus     = animalTaxonomy.Subgenus,
                    Infragenus   = animalTaxonomy.Infragenus,
                    Species      = animalTaxonomy.Species,
                    Subspecies   = animalTaxonomy.Subspecies,
                    Natio        = animalTaxonomy.Natio,
                    Morpha       = animalTaxonomy.Morpha,
                    Forma        = animalTaxonomy.Forma
                }
            };

            if (spider.Image == null)
            {
                spiderAnimalTaxonomyView.Spider.ImageUrl = "https://res.cloudinary.com/dyytlulq9/image/upload/v1609687626/logo_dirysy.png";
            }
            else
            {
                spiderAnimalTaxonomyView.Spider.ImageUrl = spider.Image.Url;
            }


            return(spiderAnimalTaxonomyView);
        }
コード例 #7
0
        public static AnimalTaxonomyModel MergeAnimalTaxonomyModelWithView(AnimalTaxonomyModel model, SpiderAnimalTaxonomyView view)
        {
            model.Regnum       = view.AnimalTaxonomy.Regnum;
            model.Subregnum    = view.AnimalTaxonomy.Subregnum;
            model.Superphylum  = view.AnimalTaxonomy.Superphylum;
            model.Phylum       = view.AnimalTaxonomy.Phylum;
            model.Subphylum    = view.AnimalTaxonomy.Subphylum;
            model.Infraphylum  = view.AnimalTaxonomy.Infraphylum;
            model.Superclassis = view.AnimalTaxonomy.Superclassis;
            model.Classis      = view.AnimalTaxonomy.Classis;
            model.Subclassis   = view.AnimalTaxonomy.Subclassis;
            model.Infraclassis = view.AnimalTaxonomy.Infraclassis;
            model.Superordo    = view.AnimalTaxonomy.Superordo;
            model.Ordo         = view.AnimalTaxonomy.Ordo;
            model.Subordo      = view.AnimalTaxonomy.Subordo;
            model.Infraordo    = view.AnimalTaxonomy.Infraordo;
            model.Superfamilia = view.AnimalTaxonomy.Superfamilia;
            model.Familia      = view.AnimalTaxonomy.Familia;
            model.Subfamilia   = view.AnimalTaxonomy.Subfamilia;
            model.Infrafamilia = view.AnimalTaxonomy.Infrafamilia;
            model.Supertrubus  = view.AnimalTaxonomy.Supertrubus;
            model.Tribus       = view.AnimalTaxonomy.Tribus;
            model.Subtribus    = view.AnimalTaxonomy.Subtribus;
            model.Infratribus  = view.AnimalTaxonomy.Infratribus;
            model.Supergenus   = view.AnimalTaxonomy.Supergenus;
            model.Genus        = view.AnimalTaxonomy.Genus;
            model.Subgenus     = view.AnimalTaxonomy.Subgenus;
            model.Infragenus   = view.AnimalTaxonomy.Infragenus;
            model.Species      = view.AnimalTaxonomy.Species;
            model.Subspecies   = view.AnimalTaxonomy.Subspecies;
            model.Natio        = view.AnimalTaxonomy.Natio;
            model.Morpha       = view.AnimalTaxonomy.Morpha;
            model.Forma        = view.AnimalTaxonomy.Forma;

            return(model);
        }