Пример #1
0
            public async Task <Response <Master> > Handle(GetMasterByIdQuery query, CancellationToken cancellationToken)
            {
                var master = await _masterRepository.GetByIdAsync(query.Id);

                if (master == null)
                {
                    throw new ApiException($"Master Not Found.");
                }
                return(new Response <Master>(master));
            }
            public async Task <Response <int> > Handle(DeleteMasterByIdCommand command, CancellationToken cancellationToken)
            {
                var master = await _masterRepository.GetByIdAsync(command.Id);

                if (master == null)
                {
                    throw new ApiException($"Master Not Found.");
                }
                await _masterRepository.DeleteAsync(master);

                return(new Response <int>(master.Id));
            }
Пример #3
0
            public async Task <Response <int> > Handle(UpdateMasterCommand command, CancellationToken cancellationToken)
            {
                var master = await _masterRepository.GetByIdAsync(command.Id);

                if (master == null)
                {
                    throw new ApiException($"Master Not Found.");
                }
                else
                {
                    master.Value    = command.Value;
                    master.Parent   = command.Parent;
                    master.Describe = command.Describe;
                    await _masterRepository.UpdateAsync(master);

                    return(new Response <int>(master.Id));
                }
            }