public async Task <Unit> Handle(Data request, CancellationToken cancellationToken) { var infringement = _infringementRepository.GetSingle(request.Id); if (infringement == null) { throw new Exception("no record found"); } _infringementRepository.Delete(infringement); var result = await _infringementRepository.Commit(); if (result > 0) { return(Unit.Value); } throw new Exception("Records were not saved"); }
public async Task <Unit> Handle(Data request, CancellationToken cancellationToken) { Guid _Id = Guid.NewGuid(); var infringement = new Infringement { Id = _Id, Description = request.Description, Points_To_Discount = request.Points_To_Discount, Status = true }; _infringementRepository.Add(infringement); var value = await _infringementRepository.Commit(); if (value > 0) { return(Unit.Value); } throw new Exception("The record was not inserted"); }