public async Task <string> Handle(CreateFightingClassCommand request, CancellationToken cancellationToken) { var fightingClass = new FightingClass { Type = request.ClassType, MaxHP = request.MaxHP, MaxMana = request.MaxMana, HealthRegen = request.HealthRegen, ManaRegen = request.ManaRegen, AttackPower = request.AttackPower, MagicPower = request.MagicPower, ArmorValue = request.ArmorValue, ResistanceValue = request.ResistanceValue, CritChance = request.CritChance, Description = request.Description, IconPath = this.imagePath.IconProcess(request.ClassType), ImagePath = this.imagePath.Process(new string[] { "Class", request.ClassType }), }; this.Context.FightingClasses.Add(fightingClass); await this.Context.SaveChangesAsync(cancellationToken); return(string.Format(GConst.AdminFightingClassCommandRedirectId, fightingClass.Id)); }
private void StatsNullCheck(UpdateFightingClassCommand request, FightingClass fightingClass) { if (!string.IsNullOrWhiteSpace(request.NewClassStype)) { fightingClass.Type = request.NewClassStype; } if (request.NewMaxHP > 0) { fightingClass.MaxHP = request.NewMaxHP; } if (request.NewMaxMana > 0) { fightingClass.MaxMana = request.NewMaxMana; } if (request.NewHealthRegen > 0) { fightingClass.HealthRegen = request.NewHealthRegen; } if (request.NewManaRegen > 0) { fightingClass.ManaRegen = request.NewManaRegen; } if (request.NewAttackPower > 0) { fightingClass.AttackPower = request.NewAttackPower; } if (request.NewMagicPower > 0) { fightingClass.MagicPower = request.NewMagicPower; } if (request.NewArmorValue > 0) { fightingClass.ArmorValue = request.NewArmorValue; } if (request.NewResistanceValue > 0) { fightingClass.ResistanceValue = request.NewResistanceValue; } if (request.NewCritChance > 0) { fightingClass.CritChance = request.NewCritChance; } if (!string.IsNullOrWhiteSpace(request.NewDescription)) { fightingClass.Description = request.NewDescription; } }