public async Task <BaseResponse <Disease> > Handle(UpdateDiseaseCommand request, CancellationToken cancellationToken)
        {
            var response = new BaseResponse <Disease> ()
            {
                ReponseName = nameof(UpdateDiseaseCommand), Content = new List <Disease> ()
                {
                }
            };
            var entity = await _diseaseRepository.GetOneAsync(p => p.Id == request.Id);

            if (entity == null)
            {
                response.Status  = ResponseType.Error;
                response.Message = $"{nameof(Disease)} not found.";
                response.Content = null;
            }
            else
            {
                _mapper.Map(request, entity, typeof(UpdateDiseaseCommand), typeof(Disease));
                await _diseaseRepository.UpdateAsync(entity);

                response.Status  = ResponseType.Success;
                response.Message = $"{nameof(Disease)} updated successfully.";
                response.Content.Add(entity);
            }
            return(response);
        }
コード例 #2
0
 public async Task UpdateDisease(Contracts.Entities.Disease disease)
 {
     await _diseaseRepository.UpdateAsync(disease);
 }
 public async Task <int> Update(Disease disease)
 {
     return(await _diseaseRepository.UpdateAsync(disease));
 }