Пример #1
0
 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);
 }
Пример #2
0
        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);
        }
Пример #3
0
 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
                                   );
 }