public ActionResult <Detail> GetDetail(int id)
        {
            Detail detail = _detailRepository.GetById(id);

            if (detail == null)
            {
                return(NotFound());
            }
            return(detail);
        }
        public async Task <DetailDTO> GetByIdAsync(long Id)
        {
            var result = await _detailRepository.GetById(Id);

            var detail = _mapper.Map <Detail, DetailDTO>(result);

            return(detail);
        }
Esempio n. 3
0
        public DetailModel GetById(int Id)
        {
            var model = repository.GetById(Id);

            var detailModel = new DetailModel
            {
                Id    = model.Id,
                Name  = model.Name,
                CarID = model.CarID
            };

            return(detailModel);
        }
Esempio n. 4
0
        public Task <bool> Handle(CreateNewDetailCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                Task.FromResult(false);
            }
            var detail = new Detail(request.DetailId, request.DetailName, request.DetailFeature, request.Category);

            if (_detailRepository.GetById(detail.DetailId) != null)
            {
                _bus.RaiseEvent(new DomainNotification(request.MessageType, "The detail has already been created."));
                return(Task.FromResult(false));
            }
            _detailRepository.Add(detail);

            if (Commit())
            {
                _bus.RaiseEvent(new DetailCreatedEvent(detail.DetailId, detail.DetailName, detail.DetailFeature, detail.Category));
            }
            return(Task.FromResult(true));
        }
Esempio n. 5
0
        internal void AddOrUpdateDetail(Order order, int detailId, int count)
        {
            var detail = detailRepository.GetById(detailId);

            if (order.Items.TryGet(detailId, out OrderItem orderItem))
            {
                orderItem.Count += count;
            }
            else
            {
                order.Items.Add(detail.Id, detail.Price, count);
            }

            orderRepository.Update(order);
        }
 public DetailViewModel GetById(int id)
 {
     return(_mapper.Map <DetailViewModel>(_detailRepository.GetById(id)));
 }
Esempio n. 7
0
        public DetailModel GetById(int id)
        {
            var detail = detailRepository.GetById(id);

            return(Map(detail));
        }