Ejemplo n.º 1
0
        public async Task <int> UpdateAsync(UpdateAssetTypeDto request)
        {
            var editAssetType = await _assetTypeRepository.GetByIdAsync(request.Id);

            var existAssetType = await _assetTypeRepository.FirstOrDefaultAsync(filter : x => x.Name.Equals(request.Name));

            if (editAssetType == null)
            {
                throw new ValidationException($"ID : {request.Id} does not exist");
            }

            if (existAssetType != null && existAssetType != null & editAssetType.Id != existAssetType.Id)
            {
                throw new ValidationException($"Name : {request.Name} already exist");
            }

            editAssetType.Name        = request.Name;
            editAssetType.Description = request.Description;
            _assetTypeRepository.Update(editAssetType);

            return(await _unitOfWork.SaveChangesAsync());
        }
Ejemplo n.º 2
0
 public bool Update(AssetType assetType, IEnumerable <AssetTypeAttribute> assetTypeAttributes)
 {
     return(_assetTypeRepository.Update(assetType, assetTypeAttributes));
 }