Пример #1
0
        public async Task <int> AddUpdateLibro(AddUpdateLibros model)
        {
            using (var connection = new SqlConnection("server=PELR90XMFFT\\SQLEXPRESS;database=DB_LIBRERIA; integrated security = true"))
            {
                {
                    SqlCommand cmd = new SqlCommand("SP_AddUpdateLibro", connection);
                    cmd.CommandType = CommandType.StoredProcedure;
                    await connection.OpenAsync();

                    // add parameters
                    cmd.Parameters.AddWithValue("@IdAsig", model.asignaturaId);
                    cmd.Parameters.AddWithValue("@Descripcion", string.IsNullOrEmpty(model.nombre) ? "" : model.nombre);
                    cmd.Parameters.AddWithValue("@Stock", model.cantidad);
                    cmd.Parameters.AddWithValue("@Libro_Id", model.libro_id);

                    SqlParameter outputParam = cmd.Parameters.Add("@Result", SqlDbType.Int);
                    outputParam.Direction = ParameterDirection.Output;
                    SqlDataReader reader = cmd.ExecuteReader();

                    int id = (int)outputParam.Value;

                    await connection.CloseAsync();

                    return(id);
                }
            }
        }
Пример #2
0
 public async Task <int> AddUpdateLibros([FromBody] AddUpdateLibros model)
 {
     return(await _libroBusinessLogic.AddUpdateLibro(model));
 }
Пример #3
0
 public Task <int> AddUpdateLibro(AddUpdateLibros model)
 {
     return(libroDataAccess.AddUpdateLibro(model));
 }