public DataEvento Adicionar(DataEvento model) { if (model.Valid) { using (RepositorySession dalSession = new RepositorySession(Runtime.JWInstance)) { IUnitOfWork unitOfWork = dalSession.UnitOfWork; unitOfWork.Begin(); try { if (_repository.PesquisarporDataeCongregacao(ref unitOfWork, model) != null) { model.AddNotification(nameof(model.Data), Errors.EventExists); unitOfWork.Rollback(); return(model); } _repository.Inserir(ref unitOfWork, model); unitOfWork.Commit(); } catch { unitOfWork.Rollback(); throw; } } } return(model); }
private DataEvento BuscarPorId(ref IUnitOfWork unitOfWork, int id) { var ret = _repository.FindById(ref unitOfWork, id); if (ret == null) { ret = new DataEvento(); ret.AddNotification(nameof(ret.Codigo), string.Format(Errors.RegisterNotFound, id)); unitOfWork.Rollback(); } return(ret); }