public static BuildUpgrade SetUpgrade(BuildUpgrade bu, GameResource currentCost)
        {
            var curRes = bu.StorageResources.Current;

            var enoughtRes = MaterialResource.EnoughResourses(curRes, currentCost);

            if (!enoughtRes)
            {
                return(bu);
            }

            var newResourse = MaterialResource.CalcNewResoursesFromBuy(curRes, currentCost);

            var upgradedData = new BuildUpgrade
            {
                StorageResources =
                    bu.StorageResources.SetStorageResource(newResourse, bu.StorageResources.Max),
                Progress = new ItemProgress
                {
                    Level      = bu.Progress.Level,
                    IsProgress = true,
                    Duration   = currentCost.TimeProduction
                },
                NativeName = bu.NativeName
            };


            return(upgradedData);
        }
        /// <summary>
        ///     Основной метод работы между  запросом к бд и записью в бд для новой очереди.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="unitType"></param>
        /// <param name="count"></param>
        /// <param name="userId"></param>
        /// <param name="ownId"></param>
        /// <param name="dbResource"></param>
        /// <param name="dbTurns"></param>
        /// <param name="setData"></param>
        private void GetTurnResultData(IDbConnection connection, UnitType unitType, int count, int userId, int ownId, StorageResources dbResource, Dictionary <UnitType, TurnedUnit> dbTurns, Action <UnitModel, StorageResources> setData)
        {
            var resource = _storageResourcesService.Execute(connection, userId, dbResource, ownId);
            var unit     = UnitHelper.GetBaseUnit(unitType);
            MaterialResource resultPrice;
            TurnedUnit       unitTurnModel;

            InitializeUnitTurn(unitType, count, resource, unit, out resultPrice, out unitTurnModel);

            AddUnitToCurrenUnitTurn(ref dbTurns, unitTurnModel);
            // подсчитываем новые ресурсы
            var newResources = resource;

            newResources.Current = MaterialResource.CalcNewResoursesFromBuy(resource.Current, resultPrice);
            setData(unit, newResources);
        }