public ExcecaoDesignacao Inserir(ExcecaoDesignacao model) { if (model.Valid) { using (RepositorySession dalSession = new RepositorySession(Runtime.JWInstance)) { IUnitOfWork unitOfWork = dalSession.UnitOfWork; unitOfWork.Begin(); try { if (_repository.ExisteExcecaoDesignacaoPorIrmaoEData(ref unitOfWork, model.IrmaoId, model.Data)) { model.AddNotification(nameof(model.Data), Errors.ExceptionsExists); unitOfWork.Rollback(); return(model); } _repository.Inserir(ref unitOfWork, model); unitOfWork.Commit(); } catch { unitOfWork.Rollback(); throw; } } } return(model); }
private ExcecaoDesignacao BuscarPorId(ref IUnitOfWork unitOfWork, int id) { var ret = _repository.FindById(ref unitOfWork, id); if (ret == null) { ret = new ExcecaoDesignacao(); ret.AddNotification(nameof(ret.Codigo), string.Format(Errors.RegisterNotFound, id)); unitOfWork.Rollback(); } return(ret); }
public void Inserir(ref IUnitOfWork unitOfWork, ExcecaoDesignacao model) { unitOfWork.Connection.Execute("p_ins_ExcecaoDesignacao", param: new { model.IrmaoId, model.Data, model.Motivo }, commandType: CommandType.StoredProcedure, transaction: unitOfWork.Transaction ); }