Exemplo n.º 1
0
        public JsonResult Edit(string jsonAssetAttributes, string assetTypes)
        {
            string error = "false";
            var    listAssetAttributes = JsonConvert.DeserializeObject <List <AssetTypeAttribute> >(jsonAssetAttributes);
            var    assetType           = JsonConvert.DeserializeObject <AssetType>(assetTypes);

            var listAllAssetType = _assetTypeService.GetAll().Where(x => x.Name.ToLower().Trim().Equals(assetType.Name.Trim().ToLower()) && assetType.ID != x.ID).SingleOrDefault();

            if (listAllAssetType != null)
            {
                error = "Name Asset Type already exists";
            }
            else
            {
                var checkUpdate = _assetTypeService.Update(assetType, listAssetAttributes);
                if (checkUpdate)
                {
                    SetAlert("Update Asset Type success", "success");
                }
                else
                {
                    SetAlert("Update Asset Type error", "error");
                }
            }


            return(Json(error));
        }