Ejemplo n.º 1
0
        public async Task <Response <PurchaseRecordDTO> > Handle(UpdatePurchaseRecordRequest request, CancellationToken cancellationToken)
        {
            var mappingProfile = new PurchaseRecordMappingProfile();
            var updated        = await _repository.Update(mappingProfile.ToEntity(request.RequestDTO));

            return(new Response <PurchaseRecordDTO>(mappingProfile.ToDto(updated)));
        }
Ejemplo n.º 2
0
        public async Task <Response <PurchaseRecordDTO> > Handle(AddPurchaseRecordRequest request, CancellationToken cancellationToken)
        {
            var purchaseRecordMappingProfile    = new PurchaseRecordMappingProfile();
            var addPurchaseRecordMappingProfile = new AddPurchaseRecordMappingProfile();
            var addedEntity = await _repository.Add(addPurchaseRecordMappingProfile.ToEntity(request.RequestDTO));

            return(new Response <PurchaseRecordDTO>(purchaseRecordMappingProfile.ToDto(addedEntity)));
        }
        public async Task <Response <List <PurchaseRecordDTO> > > Handle(GetPurchaseRecordsRequest request, CancellationToken cancellationToken)
        {
            var mappingProfile      = new PurchaseRecordMappingProfile();
            var purchaseRecordsList = await _repository.GetAll();

            var dtoList = purchaseRecordsList.Select(record => mappingProfile.ToDto(record)).ToList();

            return(new Response <List <PurchaseRecordDTO> >(dtoList));
        }