void PrintSuperman()
    {
        // Declare variables
        MetaHuman superman = new MetaHuman("Superman", 900000);

        // Printing superman
        superman.Rejuvenate(10000);
        Debug.LogFormat("{0} is {1} years old.", superman.GetName(), superman.GetAgeInYears());
        Debug.LogFormat("{0} is {1} days old.", superman.GetName(), superman.GetAgeInDays());

        superman.Age();
        Debug.LogFormat("{0} is {1} days old.", superman.GetName(), superman.GetAgeInDays());
    }
Example #2
0
        public async Task <IActionResult> Put([FromRoute] Guid id, [FromBody] MetaHumanMutateModel metaMutate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            MetaHuman metahuman = await this.metasRepository.GetOne(id);

            if (metahuman == null || id != metahuman.Id)
            {
                return(BadRequest());
            }

            if (!string.IsNullOrEmpty(metaMutate.Name))
            {
                metahuman.Name = metaMutate.Name;
            }

            if (metaMutate.Description != null)
            {
                metahuman.Description = metaMutate.Description;
            }

            if (metaMutate.AlterEgo != null)
            {
                metahuman.AlterEgo = metaMutate.AlterEgo;
            }

            metahuman.UpdatedAt = metaMutate.UpdatedAt;

            try
            {
                await this.metasRepository.UpdateAsync(metahuman);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await this.metasRepository.EntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
        public static MetaHumanViewModel BuildMetaViewModel(MetaHuman metaHuman, bool addRelations = false)
        {
            var viewmodel = new MetaHumanViewModel
            {
                Id          = metaHuman.Id,
                Name        = metaHuman.Name,
                Description = metaHuman.Description,
                AlterEgo    = metaHuman.AlterEgo,
                Status      = metaHuman.Status
            };

            if (addRelations)
            {
                viewmodel.Abilities = metaHuman.MetaHumanAbilities.Select(x => BuildAbilityViewModel(x.Ability));
                viewmodel.Teams     = metaHuman.MetaHumanTeams.Select(x => BuildTeamViewModel(x.Team));
            }

            return(viewmodel);
        }
Example #4
0
        public async Task Test2Create()
        {
            MetaHuman meta = new MetaHuman
            {
                Id          = this.id,
                Name        = "TestMeta",
                Description = "This is a meta created by the unit test",
                AlterEgo    = "Unit test",
                Status      = 0
            };

            MetaHumansController controller = new MetaHumansController(_context, null);
            IActionResult        result     = await controller.Post(meta);

            OkObjectResult ok = result as OkObjectResult;

            Assert.NotNull(ok);
            Assert.Equal(200, ok.StatusCode);
        }
Example #5
0
        public async Task <IActionResult> Post([FromBody] MetaHuman meta)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (string.IsNullOrEmpty(meta.Name))
                {
                    return(BadRequest());
                }

                MetaHuman stored = await this.metasRepository.AddAsync(meta);


                return(Ok(new { id = stored.Id }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new JsonResult(ex.Message)));
            }
        }