示例#1
0
        public async Task <CategoriaModel> Get(Guid Id)
        {
            CategoriaModel categoria = null;

            var storeProcedure = "usp_GetId_Categoria";

            try
            {
                var connection = _factoryConnection.GetConnection();
                categoria = await connection.QueryFirstOrDefaultAsync <CategoriaModel>(storeProcedure, new
                {
                    CategoriaId = Id
                }, commandType : CommandType.StoredProcedure);
            }
            catch (System.Exception e)
            {
                throw new Exception("Error en la consulta en la Base de datos", e);
            }
            finally
            {
                _factoryConnection.CloseConnection();
            }

            return(categoria);
        }
示例#2
0
        public async Task <int> Post(CategoriaModel parameters)
        {
            var storeProcedure = "usp_Post_Categoria";

            try
            {
                var connection = _factoryConnection.GetConnection();
                var resultado  = await connection.ExecuteAsync(storeProcedure, new
                {
                    CategoriaId     = Guid.NewGuid(),
                    NombreCategoria = parameters.NombreCategoria,
                    Descripcion     = parameters.Descripcion
                }
                                                               , commandType : CommandType.StoredProcedure);

                _factoryConnection.CloseConnection();

                return(resultado);
            }
            catch (System.Exception e)
            {
                throw new Exception("Error en la base de datos", e);
            }
        }