Esempio n. 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")));
        }