public async Task <IActionResult> Edit(int Id)
        {
            var robot = await robotDataService.GetRobotByIdAsync(Id);

            if (robot == null)
            {
                return(NotFound());
            }
            var model = Mapper.Map <UpdateNameBindingModel>(robot);

            return(this.View(model));
        }
        public async Task <string> UnequipWeaponAsync(int RobotId, int WeaponId)
        {
            var robot = await robotDataService.GetRobotByIdAsync(RobotId);

            if (robot == null)
            {
                return(null);
            }
            var weapon = await GetWeaponByIdFromDatabaseAsync(WeaponId);

            if (weapon == null)
            {
                return(null);
            }
            robot.Weapons.Remove(weapon);
            await DbContext.SaveChangesAsync();

            string message = $"Successfully unequipped {weapon.Name}";

            return(message);
        }
Example #3
0
        public async Task <string> UnequipArmorAsync(int RobotId, int ArmorId)
        {
            var robot = await robotDataService.GetRobotByIdAsync(RobotId);

            if (robot == null)
            {
                return(null);
            }

            var armor = await GetArmorByIdFromDatabaseAsync(ArmorId);

            if (armor == null)
            {
                return(null);
            }
            robot.Armors.Remove(armor);
            await DbContext.SaveChangesAsync();

            string message = $"Successfully unequipped {armor.Name}";

            return(message);
        }