Example #1
0
        public IResult Add(ColorAddDto colorAddDto)
        {
            //mapping
            Color color = _mapper.Map <Color>(colorAddDto);

            _colorDal.Add(color);
            return(new SuccessResult(Messages.ColorAdded));
        }
Example #2
0
        public IActionResult Add(ColorAddDto colorAddDto)
        {
            var result = _colorService.Add(colorAddDto);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Example #3
0
        public async Task <IActionResult> Add(ColorAddDto addDto)
        {
            var result = await _colorService.AddAsync(_mapper.Map <Color>(addDto));

            if (result.Success)
            {
                return(Created("", result));
            }
            return(BadRequest(result));
        }
        public async Task <IActionResult> AddAsync(ColorAddDto colorAddDto)
        {
            var result = await _colorService.AddAsync(colorAddDto);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Example #5
0
        public async Task <IResult> AddAsync(ColorAddDto colorAddDto)
        {
            Color colorToAdd = new Color()
            {
                Name = colorAddDto.Name
            };

            bool addResult = await _colorDal.AddAsync(colorToAdd);

            if (!addResult)
            {
                return(new ErrorResult(Messages.ColorNotAdded));
            }

            return(new SuccessResult(Messages.ColorAdded));
        }