Ejemplo n.º 1
0
        public async Task <IResult> UpdateAsync(ColorUpdateDto colorUpdateDto)
        {
            var ruleResult = BusinessRules.Run(await CheckColorNameExistButIgnoreByIdAsync(colorUpdateDto.Id, colorUpdateDto.Name));

            if (!ruleResult.Success)
            {
                return(ruleResult);
            }

            var findedColor = await _colorDal.GetAsync(p => p.Id == colorUpdateDto.Id);

            if (findedColor == null)
            {
                return(new ErrorResult(Messages.ColorNotFound));
            }

            findedColor.Name = colorUpdateDto.Name;

            bool updateResult = await _colorDal.UpdateAsync(findedColor);

            if (!updateResult)
            {
                return(new ErrorResult(Messages.ColorNotUpdated));
            }

            return(new SuccessResult(Messages.ColorUpdated));
        }
Ejemplo n.º 2
0
        public async Task <IResult> Update(Color color)
        {
            await _colorDal.UpdateAsync(color);

            return(new SuccessResult(Messages.ColorUpdated));
        }
Ejemplo n.º 3
0
        public async Task <IResult> UpdateAsync(Color entity)
        {
            await _colorDal.UpdateAsync(entity);

            return(new SuccessResult());
        }