public async Task <IActionResult> UpdateAsset(string id, SliceAssetDetailStringDto asset)
        {
            if (id != asset.AssetId)
            {
                return(BadRequest());
            }

            try
            {
                bool check = await _sliceService.UpdateAssetSV(id, asset);

                if (check)
                {
                    return(NoContent());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                return(BadRequest());
            };
        }
        public async Task UpdateAsset(string assetID, SliceAssetDetailStringDto asset)
        {
            SliceAsset assetModel = await _context.SliceAssets.FindAsync(assetID);

            if (assetModel == null)
            {
                return;
            }
            assetModel.Quantity    = asset.Quantity;
            assetModel.ProjectId   = asset.ProjectId;
            assetModel.Description = asset.Description;
            assetModel.TimeAsset   = asset.TimeAsset;
            assetModel.ProjectId   = asset.ProjectId;
            assetModel.TypeAssetId = asset.TypeAssetId;
            assetModel.TermId      = asset.TermId;
            assetModel.AssetSlice  = asset.AssetSlice;

            _context.Entry(assetModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public async Task <bool> UpdateAssetSV(string assetID, SliceAssetDetailStringDto asset)
        {
            switch (asset.TypeAssetId)
            {
            case 1:
            {
                double ManMonth = asset.Quantity / 160;
                double Slice    = ManMonth * Convert.ToDouble(asset.SalaryGapInTime) / (double)asset.CashPerSlice * asset.MultiplierInTime;
                asset.AssetSlice = Slice;
                break;
            }

            case 2:
            {
                double Slice = asset.Quantity / (double)asset.CashPerSlice * asset.MultiplierInTime;
                asset.AssetSlice = Slice;
                break;
            }

            case 3:
            {
                double Slice = asset.Quantity / 500000 * asset.MultiplierInTime;
                asset.AssetSlice = Slice;
                break;
            }

            case 4:
            {
                double Slice = asset.Quantity / 500000;
                asset.AssetSlice = Slice;
                break;
            }
            }
            ;
            try
            {
                await _sliceRepository.UpdateAsset(assetID, asset);

                return(true);
            }
            catch (Exception) {
                throw;
            }
        }