예제 #1
0
        public async Task <ResponseBase> InsertarDisponibilidadMunicipio(DisponibilidadDomicilio dm)
        {
            var response = new ResponseBase();

            try
            {
                using (var connection = new SqlConnection(con.getConnection()))
                {
                    using (var command = new SqlCommand("Catalogos.spInsertarDisponibilidadDomicilio", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@idDisponibilidad", 0);
                        command.Parameters.AddWithValue("@idEmpresa", dm.idEmpresa);
                        command.Parameters.AddWithValue("@idZona", dm.idZona);
                        command.Parameters["@idDisponibilidad"].Direction = ParameterDirection.Output;
                        connection.Open();
                        var result = await command.ExecuteNonQueryAsync();

                        if (result > 0)
                        {
                            response.success = true;
                            response.id      = Convert.ToInt32(command.Parameters["@idDisponibilidad"].Value);
                            response.message = "datos insertados correctamente";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.success = false;
                response.message = ex.Message;
            }
            return(response);
        }
        public async Task <ActionResult> InsertarDisponibilidadD([FromBody] DisponibilidadDomicilio dm)
        {
            var response = new ResponseBase();

            try
            {
                response = await this._disponibilidadD.InsertarDisponibilidadMunicipio(dm);
            }
            catch (Exception ex)
            {
                response.success = true;
                response.message = ex.Message;
            }
            return(Ok(response));
        }