public async Task <Result <int> > Handle(UpdateTrafficTicketCommand command, CancellationToken cancellationToken) { var item = await _repository.GetByIdAsync(command.Id); if (item == null) { return(Result <int> .Fail($"PlaceType Not Found.")); } else { item.LicensePlateNumber = command.LicensePlateNumber ?? item.LicensePlateNumber; item.Behaviour = command.Behaviour ?? item.Behaviour; item.Location = command.Location ?? item.Location; item.DateOfOffence = command.DateOfOffence ?? item.DateOfOffence; item.Device = command.Device ?? item.Device; item.Description = command.Description ?? item.Description; item.PhoneNumber = command.PhoneNumber ?? item.PhoneNumber; item.Unit = command.Unit ?? item.Unit; item.Price = command.Price ?? item.Price; item.Images = command.Images ?? item.Images; item.Status = command.Status ?? item.Status; await _repository.UpdateAsync(item); await _unitOfWork.Commit(cancellationToken); return(Result <int> .Success(item.Id)); } }
public async Task <Result <int> > Handle(DeleteTrafficTicketCommand command, CancellationToken cancellationToken) { var item = await _repository.GetByIdAsync(command.Id); await _repository.DeleteAsync(item); await _unitOfWork.Commit(cancellationToken); return(Result <int> .Success(item.Id)); }