Beispiel #1
0
        public async Task <ColorQueryDto> Handle(GetColorQueryRequest request, CancellationToken cancellationToken)
        {
            var color = await _colorRepository.GetAsync(request.ColorId);

            var colorDto = ColorMapper.Map(color);

            return(colorDto);
        }
Beispiel #2
0
        ///// <summary>
        ///// Creates a new color.
        ///// </summary>
        ///// <param name="colorDto">Color <see cref="ColorDto"/> to be created.</param>
        ///// <returns>Returns quantity of entities affected.</returns>
        //public async Task InsertAsync(ColorCommandDto colorDto)
        //{
        //    Ensure.That(colorDto, "color").EntityIsNotNull();

        //    var entity = colorDto.ToEntity();

        //   // await _colorService.ValidateAsync(entity);

        //    entity.CreationDate = DateTime.UtcNow;

        //    await _colorRepository.InsertAsync(entity);
        //}

        ///// <summary>
        ///// Updates a color.
        ///// </summary>
        ///// <param name="id">Color's id will be update.</param>
        ///// <param name="colorDto">Color <see cref="ColorDto"/> to be updated.</param>
        ///// <returns>Returns quantity of entities affected.</returns>
        //public async Task UpdateAsync(Guid id, ColorDto colorDto)
        //{
        //    Ensure.That(id, nameof(id)).IdNotEmpty();
        //    Ensure.That(colorDto, "color").EntityIsNotNull();

        //    var current = await _colorRepository.GetAsync(id);

        //    Ensure.That(current, nameof(id)).EntityExists();

        //    var color = colorDto.ToEntity();

        //    color.Id = id;

        //    await _colorService.ValidateAsync(color);

        //    current.LastModificationDate = DateTime.UtcNow;
        //    current.Name = color.Name;
        //    current.Status = color.Status;

        //    await _colorRepository.UpdateAsync(current);
        //    //await _unityOfWork.CommitAsync();
        //}

        ///// <summary>
        ///// Get all color.
        ///// </summary>
        ///// <param name="filter">Filter to define color to be returned.</param>
        ///// <param name="orderBy">Columns name to order colors.</param>
        ///// <param name="page">Current page.</param>
        ///// <param name="qtyPerPage">Quantity of registers per page.</param>
        ///// <returns>Returns a pagination list of colors <see cref="IPagination{ColorDto}"/>.</returns>
        //public async ValueTask<IPagination<ColorDto>> ListAsync(string filter = null, string orderBy = null, int page = 0, int qtyPerPage = 0)
        //{
        //    var pagination = await _colorRepository.ListAsync(filter, orderBy, page, qtyPerPage);

        //    return pagination.ToDto();
        //}

        /// <summary>
        /// Get color by id.
        /// </summary>
        /// <param name="colorId">Color id.</param>
        /// <returns>Returns color found.</returns>
        public async Task <ColorQueryDto> GetAsync(Guid colorId)
        {
            var color = await _colorRepository.GetAsync(ColorId.New(colorId));

            return(ColorMapper.Map(color));
        }