Пример #1
0
        public async Task <ActionResult> EditAsset(EditAssetModel model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#id"));
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#name"));
            }


            if (string.IsNullOrEmpty(model.EditId) || model.EditId != model.Id)
            {
                if (await _assetsRepository.GetAssetAsync(model.Id) != null)
                {
                    return(this.JsonFailResult(Phrases.AssetWithSameIdExists, "#id"));
                }
            }

            if (string.IsNullOrEmpty(model.EditId))
            {
                await _assetsRepository.RegisterAssetAsync(model);
            }
            else
            {
                await _assetsRepository.EditAssetAsync(model.EditId, model);
            }

            return(this.JsonRequestResult("#pamain", Url.Action("Index")));
        }
Пример #2
0
        public IActionResult Edit(string database, int assetTypeId, int assetId)
        {
            IActionResult action()
            {
                Guid  databaseId = this.ParseGuid(database);
                Asset asset      = this.Api.DataBase.GetAsset(databaseId, assetId);

                // TODO: Should we make this one query instead of 2?
                IAssetType     assetType  = this.Api.DataBase.GetAssetType(databaseId, assetTypeId);
                EditAssetModel assetModel = new EditAssetModel(this.Api, asset, assetTypeId, assetType, assetId);

                return(View(assetModel));
            };

            return(this.SafePerformAction(action));
        }
Пример #3
0
        public async Task Edit(EditAssetModel model)
        {
            var asset = _mapper.Map <Asset>(model);

            await _assetRepository.Edit(asset);
        }
 public async Task Edit([FromBody] EditAssetModel model)
 {
     await _assetService.Edit(model);
 }